Pages

JCL EXEC and CONDITIONAL statements

 

 JCL EXEC statements

EXEC statement treats as the beginning of the step and required for each step. A JCL can have a maximum of 255 steps.

Each step in JCL executes a program or a procedure (have one or more steps) using the EXEC statement.

Syntax :

//[stepname]  EXEC  parameters [comments]

 

Positional parameters

PGM

to specify the program that needs to be run by the system. The program name specified with PGM should be a clean compiled program ready to execute.

//STEP1    EXEC PGM=SAMPLE

PROC

to specify the procedure that needs to be run by the system. The procedure can be an instream or cataloged.

//STEP01  EXEC MTHPROC

Keyword parameters

ACCT

Specifies step accounting information.

ADDRSPC

Specifies the type of the storage required for the step.

COND

Specifies the return code tests used to determine the specific step execution.

MEMLIMIT

Specifies the limit on total number of usable virtual pages above the bar.

RD

Specifies the user authority for automatic restart.

REGION

Specifies the Maximum amount of space required by the step.

TIME

Specifies the Maximum amount of processor time the step can use.



        CONDITIONAL STATEMENTS

To control the execution flow within a job based on certain conditions.

They allow us to specify when a particular job step should be executed or skipped. 

 

IF statement

It defines a condition with the return code or condition code of the previous steps.

If the condition is true, then the step that follows the IF statement gets executed, and if the condition is false, the step execution gets skipped.

Example - Executing STEP02 when STEP01 abended or RC > 8.

//Jobcard

//STEP01   DD PGM=PROG1

//IFSTEP2  IF ( ABEND | STEP01.RC > 8 ) THEN

//STEP02   EXEC PGM=PROG2

//IFSTEP2E ENDIF

//STEP03   EXEC PGM=PROG3

COND parameter

to specify a condition under which a particular job step should be executed or skipped.

It allows us to control the flow of execution within a job based on the result code (return code) of a previous job step or based on other conditions.

COND=EVEN

can be coded only at step level and is used to execute the current step when the previous step execution is successful or unsuccessful.   

COND=ONLY

can be coded only at step level and is used to execute the current step when the previous step execution is unsuccessful

COND=(return-code|RC,operator|RO)

If COND=(RC,RO) is true, the step with COND parameter execution will be bypassed

COND=(return-code|RC,operator|RO[,step-name1][.proc-step-name1])

RD parameter

RD stands for restart definition.

used to - allow JES to perform an automatic job restart after the job failure, allow the operator to perform an automatic job or a checkpoint restart if a job fails.

Syntax -
RD={R }
{RNC}
{NR }
{NC }

R - Specifies restart, checkpoints.

RNC - Specifies restart, no checkpoints.

NR - Specifies no restart, checkpoints.

NC - Specifies no restart, no checkpoints.

Example - Automatic restart for job level and No restart at step level.

//MTHEXMP1 JOB (META007),'PAWAN Y',RD=R

//*

//STEP01 EXEC ...

//STEP02 EXEC ...

//STEP03 EXEC ...

//STEP04 EXEC PGM=PROG04,RD.STEP02=NR

//STEP05 EXEC PGM=PROG05

RD=R specifies that the operator can perform automatic restart if the job fails.

The RD parameter at the STEP04 is ignored.

 


No comments:

Post a Comment