

# 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.