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:
- JOB Statement
- EXEC Statement
- DD (Data Definition) Statements
- 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:
Example:
- 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:
Example:
- 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:
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 nameMYJOB01
, accounting information12345
, a description'Sample Job'
, and specifies the job classA
and message classX
. - EXEC Statement (
//STEP1 EXEC PGM=IEFBR14
): Specifies that the programIEFBR14
(a utility program) will be executed in stepSTEP1
. - DD Statements:
- INPUT01 (
//INPUT01 DD DSN=MY.DATA.SET, DISP=SHR
): Defines an input data setMY.DATA.SET
with a disposition ofSHR
(shared). - OUTPUT01 (
//OUTPUT01 DD DSN=MY.OUTPUT.SET, DISP=(NEW,CATLG,DELETE), UNIT=SYSDA, SPACE=(CYL,(1,1))
): Defines an output data setMY.OUTPUT.SET
with a disposition ofNEW
(new data set),CATLG
(catalog the data set if the job completes successfully), andDELETE
(delete the data set if the job fails). It also specifies the unitSYSDA
and space allocation(CYL,(1,1))
.
- INPUT01 (
Practical Exercise
Exercise: Write a JCL job that:
- Defines a job named
TESTJOB
. - Executes a program named
SORT
. - Uses an input data set
TEST.INPUT.DATA
with a disposition ofSHR
. - Creates an output data set
TEST.OUTPUT.DATA
with a disposition ofNEW
, 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.
JCL (Job Control Language) Course
Module 1: Introduction to JCL
Module 2: JCL Statements and Syntax
Module 3: Data Definition (DD) Statements
Module 4: Procedures and Symbolic Parameters
Module 5: Advanced JCL Concepts
- Conditional Processing
- JCLLIB and INCLUDE Statements
- Generation Data Groups (GDGs)
- Restart and Checkpoint
Module 6: Error Handling and Debugging
- Common JCL Errors
- Interpreting JCL Error Messages
- Debugging Techniques
- Using JES2/JES3 for Troubleshooting