

# AWS Mainframe Modernization on Amazon EC2 integration with Control-M
<a name="aws-mainframe-modernization-ec2"></a>

This section describes how Control-M integrates with and supports batch jobs that run in a custom AWS Mainframe Modernization runtime environment deployed on an EC2 instance. If you are implementing the fully managed AWS Replatform with Micro Focus runtime environment, see the [Managed AWS Mainframe Modernization integration with Control-M](aws-mainframe-modernization-managed.md) section.

This section assumes the following prerequisites:
+ An active AWS account.
+ A virtual private cloud (VPC) where the EC2 instances will be created.
+ The mainframe application is migrated and running in an AWS Replatform with Micro Focus environment on an EC2 instance and is supporting the Micro Focus runtime engine with multiple defined batch jobs. For this pilot, follow the instructions at [Replatforming applications with Micro Focus](https://docs.aws.amazon.com/m2/latest/userguide/replatforming-m2.html). The documentation includes all tasks and additional information on configuring and operating the AWS Replatform with Micro Focus runtime environment on Amazon EC2.

This following topics cover the setup required for integration between Control-M and the AWS Replatform with Micro Focus environment:
+ [Deploy Control-M and Micro Focus resources](deploy-resources-environment.md)
+ [Create a Control-M connection profile](create-control-m-connection-profile.md)
+ [Create jobs and schedules in Control-M Planning](create-jobs-schedules-control-m-planning.md)
+ [Manage job runs in Control-M by using Monitoring](monitor.md)

# Deploy Control-M and Micro Focus resources
<a name="deploy-resources-environment"></a>

The first two steps in integrating AWS Mainframe Modernization with Control-M are to deploy a Control-M Agent and then deploy a plug-in on the Agent. The third step is to deploy the job type in Control-M Application Integrator.

## Deploy a Control-M Agent on an EC2 instance
<a name="deploy-agent"></a>

When using a custom AWS Replatform with Micro Focus on Amazon EC2 runtime environment, the `MFBSIFJCL` utility is invoked. The utility operates on the host that was launched using the Micro Focus Enterprise Server offer from the AWS Marketplace. To run the `MFBSIFJCL` utility, you must also deploy a Control-M Agent on that host. For instructions, see the [Control-M documentation](https://documents.bmc.com/supportu/9.0.21/en-US/Documentation/Agent_Installation.htm).

**Note**  
You can download required installation media from the [BMC Electronic Product Download site](https://www.bmc.com/support/resources/product-downloads.html).

## Deploy the Micro Focus plug-in on the Control-M Agent
<a name="deploy-plug-in"></a>

Plug-ins provide integration and support for the applications and services that Control-M orchestrates.

The plug-in deployment is an infrequent activity. If you already have an existing plug-in that you want to use, skip this step, and create a connection profile.

On Amazon EC2, the AWS Mainframe Modernization Replatform with Micro Focus service exposes the Micro Focus engine. To integrate AWS Mainframe Modernization, Control-M uses the Micro Focus plug-in. For more information, see the [Control-M documentation](https://docs.bmc.com/docs/ctm_integrations/control-m-for-micro-focus-1193641959.html).

You must deploy this plug-in to an Agent that is installed on a host where Micro Focus Enterprise Server is running.

## Deploy an AWS Mainframe Modernization job type in Control-M Application Integrator
<a name="application-integrator"></a>

The job type deployment is usually a one-time activity. If you already have an existing job type that you want to use, skip this step and move on to the next step of [creating a connection profile](create-control-m-connection-profile.md).

The example job type [AIJOB.ctmai ](https://github.com/aws-samples/aws-mainframe-modernization-controlm-integration/blob/main/assets/AIJOB.ctmai)is supplied in the git repository. To deploy a job type, you must perform the following steps using [Application Integrator](https://documents.bmc.com/supportu/9.0.21/en-US/Documentation/Application_Integrator.htm):
+ Clone the [aws-mainframe-modernization-controlm-integration](https://github.com/aws-samples/aws-mainframe-modernization-controlm-integration) GitHub repository and download the `AIJOB.ctmai`  file to a file system location that can be accessed by Application Integrator.
+ Log in to Application Integrator.
+ On the **Home** tab, select **Import job type from file**, and select the location of `AIM2JOB.ctmai`.
+ If you want to make any modifications to the supplied example, familiarize yourself with Application Integrator.
+ Deploy the job type by following the instructions in the [Control-M documentation](https://documents.bmc.com/supportu/9.0.21/en-US/Documentation/Deploying_and_Publishing_a_Plug-in.htm).

# Create a Control-M connection profile
<a name="create-control-m-connection-profile"></a>

Connection profiles define connection attributes and security credentials for a specific instance of an application. Each connection profile can be referenced by multiple jobs. You can have separate profiles for each unique combination of an application and credentials.

To define connection profiles, you can use the [Configuration domain](https://documents.bmc.com/supportu/9.0.21/en-US/Documentation/Creating_a_centralized_connection_profile.htm) of the Control-M Web interface, or you can use JSON. The following code is an example of using JSON:

```
{
  "MICROFOCUS-WINDOWS": {

  "Type": "ConnectionProfile:Micro Focus Windows",
  "Centralized": true,
  "Description": "Micro Focus on Windows Connection Profile - file locations refer to the Enterprise Server host", "MFBSI Config Path": "C:\\microfocus\\ES\\mfbsi\\MFWIN\\mfbsi.cfg",
  "MFBSI Directory Path": "c:\\microfocus\\es\\mfbsi\\MFWIN",
  "Runtime Environment": "\"C:\\Program Files (x86)\\Micro Focus\\Enterprise Developer\\createenv.bat\"", "Run As": "dbauser",
  "RunAs-Pass": "*****"
  }
}
```

The example code is in the file `ConnectionProfile-Custom-M2-Replatform.json` in the GitHub repo. To deploy the code, use the Control-M Automation API deploy service:

```
ctm deploy ConnectionProfile-Custom-M2-Replatform.json
```

The response from the Control-M Automation API will be similar to the following:

```
[ 
 {
    "deploymentFile": "cp-JOG-MF-WINDOWS.json", 
    "deploymentState": "DEPLOYED_CONNECTION_PROFILES", 
    "deploymentStatus": "ENDED_OK", 
    "successfulFoldersCount": 0, 
    "successfulSmartFoldersCount": 0, 
    "successfulSubFoldersCount": 0,
    "successfulJobsCount": 0, 
    "successfulConnectionProfilesCount": 1, 
    "successfulDriversCount": 0, 
    "isDeployDescriptorValid": false, 
    "deployedConnectionProfiles": [ " MICROFOCUS-WINDOWS " ]
  }
]
```

# Create jobs and schedules in Control-M Planning
<a name="create-jobs-schedules-control-m-planning"></a>

Now that you have the plug-in deployed and a connection profile for Micro Focus connectivity, you can start creating and running jobs.

Each Control-M for Micro Focus job consists of a set of attributes, in four sections. Each section can have many attributes. The following list shows some of the more commonly used attributes.
+ General:
  + The job name
  + The application and sub-application that the job belongs to
  + The JCL to submit
  + A link to site-provided operational documentation
+ Scheduling:
  + Months and Days this job is eligible to run
  + Calendars such as a business accounting periods, holidays, or other special dates that cannot be defined algorithmically
  + Time windows
  + Cyclic behavior such as running every hour
+ Prerequisites
  + Upstream dependencies (usually jobs, which must be completed successfully before this job becomes eligible to run)
  + Resources that might be required
  + User action that might be required
+ Actions performed by Control-M upon completion of the job:
  + Determining job success or failure (usually based on the job's completion codes, but you can override that setting to use output text or checks for a specific status)
  + Notifications, such as email, for failure or success
  + Publishing status for downstream dependencies

As with connection profiles, jobs can be created and deployed by [using Control-M Web](https://documents.bmc.com/supportu/9.0.21/en-US/Documentation/Creating_a_Job.htm) or [written in JSON](https://docs.bmc.com/docs/automation-api/monthly/code-reference-1116950299.html) and deployed by using Control-M Automation API.

The following sections examine some common workflow scenarios:
+ [Initiate jobs by using a workflow](initiate-jobs.md)
+ [Automate job runs on a scheduled frequency](automate-jobs.md)

# Initiate jobs by using a workflow
<a name="initiate-jobs"></a>

Create a flow of jobs called a workflow. Jobs in the workflow are interconnected with dependencies on successful completion of the previous jobs.

## Using Control-M Web
<a name="control-m-web"></a>

To initiate a job from the Control-M user interface, do the following:

1. In the Planning domain, add a new Workspace. This opens a canvas with an empty folder object.

1. On the Menu bar, choose **Add Job**, choose the Micro Focus Windows or Micro Focus Linux job, and drag it onto the face of the folder.

1. After the color of the job changes to green, drop it. The pane on the right contains the **General**, **Scheduling**, **Prerequisites**, and **Actions** sections. To create the job, see the standard instructions in the [Control-M documentation](https://documents.bmc.com/supportu/9.0.21/en-US/Documentation/Creating_a_Job.htm).

1. For instructions on building a Control-M for Micro Focus job, see the [Control-M documentation](https://documents.bmc.com/supportu/9.0.21/en-US/Documentation/Jobs_for_Mainframe_Modernization.htm#MicroFocusJob). For this pilot, repeat steps 2–4 for five jobs, naming each one from `aws-mf-job1` to `aws-mf-job5`.

1. To connect these jobs into the flow that you want, choose the condition triangle under the job object, and drag it onto the next job. For example, choose the condition triangle under `aws-mf-job1`, and drag it onto `aws-mf-job2`. This action makes `aws-mf-job1` the predecessor of `aws-mf-job2`. By default, `aws-mf-job1` must now be completed successfully before `aws-mf-job2` becomes eligible to run.

The following diagram shows the Control-M Planning view of the basic job flow.



![\[Workflow diagram, with properties in the right-side pane.\]](http://docs.aws.amazon.com/prescriptive-guidance/latest/control-m-batch-scheduler/images/control-m-web-planning.png)


*Image provided courtesy of BMC Software, Inc. ©2022*

## Using JSON
<a name="json"></a>

The same flow can be coded in JSON. In the GitHub repo, the example code is in the file `Folder-Custom-M2-Replatform.json`:

```
{
  "aws-custom-m2": {
    "Type": "Folder",
    "ControlmServer": "psctm",
    "OrderMethod": "Manual",
    "Application": "AWSM2",
    "SubApplication": "Replatform-Custom",
    "aws-mf-job1": {
      "Type": "Job:Micro Focus Windows",
      "ConnectionProfile": "MICROFOCUS-WINDOWS",
      "Enable JCL Variables": "unchecked",
      "Restart on Rerun": "unchecked",
      "Recapture ABEND Codes": "Ignore",
      "Recapture COND Codes": "Ignore",
      "Auto Adjust Restart": "Ignore",
      "Set MF_UCC11": "Ignore",
      "Restart with Modified JCL": "No",
      "Application": "AWSM2",
      "SubApplication": "Replatform-Custom",
      "Host": "microfocus-es-host",
      "Output": {}
    },
    "aws-mf-job2": {
      "Type": "Job:Micro Focus Windows",
      "ConnectionProfile": "MICROFOCUS-WINDOWS",
      "Enable JCL Variables": "unchecked",
      "Restart on Rerun": "unchecked",
      "Recapture ABEND Codes": "Ignore",
      "Recapture COND Codes": "Ignore",
      "Auto Adjust Restart": "Ignore",
      "Set MF_UCC11": "Ignore",
      "Restart with Modified JCL": "No",
      "Application": "AWSM2",
      "SubApplication": "Replatform-Custom",
      "Host": "microfocus-es-host",
      "Output": {}
    },
    "aws-mf-job3": {
      "Type": "Job:Micro Focus Windows",
      "ConnectionProfile": "MICROFOCUS-WINDOWS",
      "Enable JCL Variables": "unchecked",
      "Restart on Rerun": "unchecked",
      "Recapture ABEND Codes": "Ignore",
      "Recapture COND Codes": "Ignore",
      "Auto Adjust Restart": "Ignore",
      "Set MF_UCC11": "Ignore",
      "Restart with Modified JCL": "No",
      "Application": "AWSM2",
      "SubApplication": "Replatform-Custom",
      "Host": "microfocus-es-host",
      "Output": {}
    },
    "aws-mf-job4": {
      "Type": "Job:Micro Focus Windows",
      "ConnectionProfile": "MICROFOCUS-WINDOWS",
      "Enable JCL Variables": "unchecked",
      "Restart on Rerun": "unchecked",
      "Recapture ABEND Codes": "Ignore",
      "Recapture COND Codes": "Ignore",
      "Auto Adjust Restart": "Ignore",
      "Set MF_UCC11": "Ignore",
      "Restart with Modified JCL": "No",
      "Application": "AWSM2",
      "SubApplication": "Replatform-Custom",
      "Host": "microfocus-es-host",
      "Output": {}
    },
    "aws-mf-job5": {
      "Type": "Job:Micro Focus Windows",
      "ConnectionProfile": "MICROFOCUS-WINDOWS",
      "Enable JCL Variables": "unchecked",
      "Restart on Rerun": "unchecked",
      "Recapture ABEND Codes": "Ignore",
      "Recapture COND Codes": "Ignore",
      "Auto Adjust Restart": "Ignore",
      "Set MF_UCC11": "Ignore",
      "Restart with Modified JCL": "No",
      "Application": "AWSM2",
      "SubApplication": "Replatform-Custom",
      "Host": "microfocus-es-host",
      "Output": {}
    },
    "leftbranch": {
      "Type": "Flow",
      "Sequence": [
        "aws-mf-job1",
        "aws-mf-job2",
        "aws-mf-job3",
        "aws-mf-job5"
      ]
    },
    "rightbranch": {
      "Type": "Flow",
      "Sequence": [
        "aws-mf-job2",
        "aws-mf-job4",
        "aws-mf-job5"
      ]
    }
  }
}
```

To deploy this flow, use the Control-M Automation API:

```
ctm deploy Folder-Custom-M2-Replatform.json
```

# Automate job runs on a scheduled frequency
<a name="automate-jobs"></a>

Using the flow that you created in the previous steps, you can add basic and runtime scheduling.
+ Basic scheduling defines which days a job is eligible to run (for example, every weekday, only on working days, month end, or quarter end). You can set the basic scheduling on the [Scheduling](https://documents.bmc.com/supportu/9.0.21/en-US/Documentation/Job_scheduling.htm) tab.
+ Runtime scheduling determines when a job runs on the day that it's eligible to run (for example, after predecessor jobs complete, every hour, after specified resources are available, or only after manual confirmation).

You can define some runtime scheduling in the **Scheduling** section and others in **Prerequisites** section.

# Monitor jobs
<a name="monitor"></a>

You can monitor and verify jobs in the Control-M Monitoring domain and in the [Micro Focus Enterprise Server Common Web Administration user interface](https://www.microfocus.com/documentation/visual-cobol/vc70/CSWin/GUID-C7A333B6-1DFB-49AC-8DB3-4023C6FCDEFB.html).

## Control-M Monitoring
<a name="monitoring"></a>

Job submissions and runs can be monitored in the Control-M Monitoring domain. By default, AWS Mainframe Modernization service jobs will appear together with all other Control-M work. If you want to see only the AWS Mainframe Modernization service jobs without any other workload (or any other filtering requirements), you can create a Viewpoint.

Viewpoints show not only job information but also relationships with upstream and downstream dependencies. Additionally, if your workflow includes AWS Mainframe Modernization and other types of Control-M jobs, you can see and manage the entire flow in the Monitoring domain.

You can follow detailed steps by visiting [Viewpoints section of Monitoring](https://documents.bmc.com/supportu/9.0.21/en-US/Documentation/Viewpoints.htm) in the Control-M documentation.

The following screenshot shows the outputs of two workflows. On the left side, the workflow is completed successfully with all five jobs in green. On the right side, the workflow is only partially successful because `aws-mf-job3` returned the **Failed** status, and the workflow stopped there, leaving `aws-mf-job5` in **Wait Schedule** state.



![\[Workflow diagrams on the left side, monitoring output on the Output tab on the right-side pane.\]](http://docs.aws.amazon.com/prescriptive-guidance/latest/control-m-batch-scheduler/images/monitor-jobs-2.png)


*Image provided courtesy of BMC Software, Inc. ©2022*