Jcl TopicsIntroduction 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 questions
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).
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.
This is the keyword which identifies the statement as EXEC statement.
There are 2 positional parameters to identify the module to execute. They are called PGM and PROC.
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 ...........
This refers to the procedure name to be executed.
//PROGPUB JOB NOTIFY=&SYSUID,MSGCLASS=AMSGLEVEL=2 //STEP1 EXEC PROC=PROCNAME //DD ...........
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.
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
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))
|GE||Greater than or equal to|
|NE||Not equal to|
|LE||Less than or equal to|
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
When this is coded in a step, that particular step is executed even if the previous step ends abnormally.
When this is coded in a step, that particular step is executed only if the previous step ends abnormally.
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.
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
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..........