In this section, we will explore the fundamental structure of a JCL (Job Control Language) job. Understanding the basic structure is crucial for writing and managing JCL scripts effectively. We will break down the components of a JCL job and provide practical examples to illustrate each part.

Key Components of a JCL Job

A JCL job typically consists of the following key components:

  1. JOB Statement
  2. EXEC Statement
  3. DD (Data Definition) Statements

  1. JOB Statement

The JOB statement marks the beginning of a JCL job and provides information about the job to the operating system. It includes details such as job name, accounting information, and job parameters.

Syntax:

//JOBNAME JOB (accounting_info), 'job_description', CLASS=class, MSGCLASS=msgclass, ...

Example:

//MYJOB01 JOB (12345), 'Sample Job', CLASS=A, MSGCLASS=X

  1. EXEC Statement

The EXEC statement specifies the program or procedure to be executed. It can call a program directly or invoke a cataloged or in-stream procedure.

Syntax:

//STEP1 EXEC PGM=program_name

Example:

//STEP1 EXEC PGM=IEFBR14

  1. DD (Data Definition) Statements

DD statements define the data sets (files) that the program or procedure will use. They specify the input and output data sets, their attributes, and how they should be handled.

Syntax:

//DDNAME DD DSN=data_set_name, DISP=disposition, ...

Example:

//INPUT01 DD DSN=MY.DATA.SET, DISP=SHR
//OUTPUT01 DD DSN=MY.OUTPUT.SET, DISP=(NEW,CATLG,DELETE), UNIT=SYSDA, SPACE=(CYL,(1,1))

Example of a Complete JCL Job

Let's put together a simple JCL job that demonstrates the basic structure:

//MYJOB01 JOB (12345), 'Sample Job', CLASS=A, MSGCLASS=X
//STEP1   EXEC PGM=IEFBR14
//INPUT01 DD DSN=MY.DATA.SET, DISP=SHR
//OUTPUT01 DD DSN=MY.OUTPUT.SET, DISP=(NEW,CATLG,DELETE), UNIT=SYSDA, SPACE=(CYL,(1,1))

Explanation:

  • JOB Statement (//MYJOB01 JOB ...): Defines the job with a name MYJOB01, accounting information 12345, a description 'Sample Job', and specifies the job class A and message class X.
  • EXEC Statement (//STEP1 EXEC PGM=IEFBR14): Specifies that the program IEFBR14 (a utility program) will be executed in step STEP1.
  • DD Statements:
    • INPUT01 (//INPUT01 DD DSN=MY.DATA.SET, DISP=SHR): Defines an input data set MY.DATA.SET with a disposition of SHR (shared).
    • OUTPUT01 (//OUTPUT01 DD DSN=MY.OUTPUT.SET, DISP=(NEW,CATLG,DELETE), UNIT=SYSDA, SPACE=(CYL,(1,1))): Defines an output data set MY.OUTPUT.SET with a disposition of NEW (new data set), CATLG (catalog the data set if the job completes successfully), and DELETE (delete the data set if the job fails). It also specifies the unit SYSDA and space allocation (CYL,(1,1)).

Practical Exercise

Exercise: Write a JCL job that:

  1. Defines a job named TESTJOB.
  2. Executes a program named SORT.
  3. Uses an input data set TEST.INPUT.DATA with a disposition of SHR.
  4. Creates an output data set TEST.OUTPUT.DATA with a disposition of NEW, catalog the data set if the job completes successfully, and delete it if the job fails. Allocate space in tracks (TRK,(5,5)).

Solution:

//TESTJOB  JOB (67890), 'Test Job', CLASS=B, MSGCLASS=Y
//STEP1    EXEC PGM=SORT
//INPUT01  DD DSN=TEST.INPUT.DATA, DISP=SHR
//OUTPUT01 DD DSN=TEST.OUTPUT.DATA, DISP=(NEW,CATLG,DELETE), UNIT=SYSDA, SPACE=(TRK,(5,5))

Summary

In this section, we covered the basic structure of a JCL job, including the JOB, EXEC, and DD statements. We provided a complete example and a practical exercise to reinforce the concepts. Understanding these fundamental components is essential for writing and managing JCL scripts effectively. In the next section, we will delve deeper into the specifics of JCL statements and their syntax.

© Copyright 2024. All rights reserved