Jcl
Introduction to JCL Jcl coding sheet JOB Statement Exec statement DD Statement Concatenating Datasets Referback in JCL Special DD statements Utility Programs Utility program IEBGENER Utility programs IEBCOPY and IEBCOMPR DFSort DFSort reformat dataset DFSort INCLUDE OMIT COND Procedures generation data group (GDG) JCL quick study JCL Interview questionsEXEC Statement
A JCL can have multiple steps and each step needs to have a the EXEC statement which holds the information on the program/procedure to execute. One JOB can hold upto 255 steps.
//Stepname EXEC ,
The EXEC statement is used to
- Mark the beginning of each step in a job.
- Used to identify the program or procedure (cataloged or in-stream).
STEPNAME:
This identifies the job step names with in the JCL and the length is 1 to 8 bytes alphanumeric characters. This is an optional field. However, it is advised to name the steps used in JCL in order to refer-back or check errors.
EXEC:
This is the keyword which identifies the statement as EXEC statement.
Positional Parameters:
There are 2 positional parameters to identify the module to execute. They are called PGM and PROC.
PGM:
This parameter is used to define a load module of a program or load module of any utility programs like SORT.
//PROGPUB JOB NOTIFY=&SYSUID,MSGCLASS=AMSGLEVEL=2
//STEP1 EXEC PGM=PROGRAM1
//DD ...........
PROC:
This refers to the procedure name to be executed.
//PROGPUB JOB NOTIFY=&SYSUID,MSGCLASS=AMSGLEVEL=2
//STEP1 EXEC PROC=PROCNAME
//DD ...........
Keyword Parameters:
In addition to the positional parameter indicating the program or procedure to run, the EXEC statement also may contain keyword parameters. If you code one of these keyword parameters on the EXEC statement, the keyword parameter value will apply only to that step. List of commonly used keyword parameters are explained here. For more information on the complete list of keyword parameters please refer to IBM manual.
PARM:
This parameter is used to send data to the program and it depends on the program for the values to send. Maximum of 100 bytes of data can be sent to the program via this field.
//*Program getting an input using PARM field which is accepted in program via linkage section
//STEP1 EXEC PGM=PROGRAM1,PARM='INPUT
COND:
The COND parameter defines the condition on which the step should be executed or bypassed. We can code up to 8 comparison conditions for a step. If the condition parameter is coded in JOB and STEP statement, the STEP value overrides the JOB condition statement. The syntax is
COND=(RETURN CODE,RELATIONAL OPERATOR,STEPNAME)
//*The LKED step will be executed only if the condition coded is not true.
//COBOL EXEC PGM=IGYCRCTL
//DD .....
//LKED EXEC PGM=HEWL,COND=(4,LT,COBOL)
//*The LKED step will be executed only if the condition coded is not true. So, it is executed if the return code is 5,6.
//COBOL EXEC PGM=IGYCRCTL
//DD .....
//LKED EXEC PGM=HEWL,COND=((4,GT),(7,LT))
Comparison operators
Relational Operator | Description |
GT | Greater than |
EQ | Equal to |
LT | Less than |
GE | Greater than or equal to |
NE | Not equal to |
LE | Less than or equal to |
Examples:
COND = (7, LT)
Any return code less than or equal to 7 allows the job to continue.
COND = ((20,GE),(30,LT))
Any return code of 21 through 30 allows the job to continue.
The COND also takes values 'EVEN' or 'ONLY'. The JOB abends if any of the step ends abnormally. So, to continue the JOB execution even if one of the step abends, the following conditions are coded
COND=EVEN
When this is coded in a step, that particular step is executed even if the previous step ends abnormally.
COND=ONLY
When this is coded in a step, that particular step is executed only if the previous step ends abnormally.
TIME:
TIME parameter when coded in a job STEP, the time specified applies to the STEP. If TIME is specified in both the JOB and STEP statement, then both will be in effect and may cause error.
TIME=(minutes,seconds) where MINUTES <= 1440 and SECONDS < 60
//*Program with TIME limit specified for the step
//STEP1 EXEC PGM=PROGRAM1,TIME=(0,5)
//*Program with TIME limit specified in JOB and STEP statements
//*This JOB will throw an error if the STEP1 is executed beyond 2 seconds as the entire JOB has a time limit of 2 seconds while the step has a time limit of 5 seconds.
//PROGPUB JOB (012),'JOHN DOE',TIME=(,2)
//STEP1 EXEC PGM=PROGRAM1,TIME=(0,5)
TIME=(6,20) - Max CPU Time = 380 seconds
TIME=3 - Max CPU Time = 3 minutes
TIME=(,20) - Max CPU Time = 20 seconds
TIME=NOLIMIT - Same as TIME=1440. Indicates job can use the processor
for an unlimited amount of time.
REGION:
The REGION parameter specifies the amount of virtual storage a STEP can use. When the REGION parameter is coded in a STEP, the amount of storage allocated is for that particular step. Syntax is
REGION=(nK/nM)
where n ranges from 1k to 2096128k in kilobytes and 1M to 2047M in Megabytes.
When the region parameter is coded with 0k or 0m, the system allocates optimum storage for that step.
If a REGION parameter is coded in STEP and JOB statements, the JOB statement overrides the EXEC statement in any step.
//*A step with REGION parameter
//STEP1 EXEC PGM=PROGRAM1,REGION=10M
//DD..........
//STEP2 EXEC PGM=PROG2,REGION=2M
//DD..........
//*REGION coded in both JOB and EXEC statements
//*Each step is allocated 5M of storage
//PROGPUB JOB NOTIFY=&SYSUID,REGION=5M
//STEP1 EXEC PGM=PROGRAM1,REGION=10M
//DD..........
//STEP2 EXEC PGM=PROG2,REGION=2M
//DD..........