COND Parameter


Note! COND parameter can be coded at the job level and step level.

The COND parameter is used to implement conditional processing within a JCL.

It helps to validate the return code to determine whether a job will continue the processing or not. The job processing will continue when the condition is false and terminates when the condition is true.

It can code with eight conditions at the maximum, and those are separated by () and a comma. It is optional and used to override the system's default sequence of execution.

Syntax for JOB statement (JOB level) -

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

Syntax for EXEC statement (Step level) -

COND=EVEN
COND=ONLY
COND=(return-code|RC,operator|RO)
COND=(return-code|RC,operator|RO[,step-name1][.proc-step-name1])
Return-code | RC RC is the Return Code of the precious step. The valid RC values are from 0 to 4095.
Operator | RO RO is the Relational Operator used to validate the return code. The valid Relational Operator are -
OperatorMeaning
GTGreater than
GEGreater than or equal to
EQEqual to
LTLess than
LELess than or equal to
NENot equal to
proc-step-name Specifies procedure stepname
step-name Specifies the stepname of which the RC validated.

COND parameter types -


COND parameter is divided into four types based on their usage -

  • COND=ONLY (Applicable to STEP)
  • COND=EVEN (Applicable to STEP)
  • COND=(RC,RO)
  • COND=(RC,RO,Step-name)

COND=ONLY -


COND=ONLY can be coded only at step level. ONLY parameter is used to execute the current step (where the COND parameter is coded) when the previous step execution is unsuccessful.

Syntax -

COND=ONLY

Example -

//MTHEXMP1 JOB (META007),'PAWAN Y',NOTIFY=&SYSUID
//STEP1 EXEC PGM=P1 
//STEP2 EXEC PGM=P2 
//STEP3 EXEC PGM=P3,COND=ONLY 
//STEP4 EXEC PGM=P4 

STEP3 execution is depending on the STEP2 execution status. The below table shows the possible output comes -

STEP2 executed-->STEP3 won't execute
STEP2 not executed-->STEP3 will execute

COND=EVEN -


COND=ONLY can be coded only at step level. EVEN parameter used to execute the current step (where the COND parameter is coded) when the previous step execution is successful or unsuccessful. COND=EVEN ignores the previous step return code and always executes the current step.

Syntax -

COND=EVEN

Example -

//MTHEXMP1 JOB (META007),'PAWAN Y',NOTIFY=&SYSUID
//STEP1 EXEC PGM=P1
//STEP2 EXEC PGM=P2
//STEP3 EXEC PGM=P3,COND=EVEN
//STEP4 EXEC PGM=P4 

STEP3 always executes regardless of the STEP2 return code. The below table shows the possible output comes -

STEP2 executed-->STEP3 will execute
STEP2 not executed-->STEP3 will execute

COND=(RC,RO) -


COND=(RC,RO) can be coded at job level and step level. It is used to execute the current step (where the COND parameter is coded) based on the previous step return code (RC). If COND=(RC,RO) is true, the step with COND parameter execution will be bypassed. If COND=(RC,RO) is false, the step with the COND parameter will be executed.

Syntax -

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

Example -

//MTHEXMP1 JOB (META007),'PAWAN Y',NOTIFY=&SYSUID
//STEP1 EXEC PGM=P1
//STEP2 EXEC PGM=P2
//STEP3 EXEC PGM=P3,COND=(12,NE) 
//STEP4 EXEC PGM=P4

The below table shows the possible output comes -

STEP2 RC=12-->STEP3 should execute
STEP2 RC<>12-->STEP3 will not execute

Understanding the COND execution -

If COND= (RC, RO) is true for the previous step, then the current step execution is bypassed. If COND= (RC, RO) is false, then the current step gets executed.

Let us assume COND parameter is coded at JOB Card and each step in the job should not satisfy the condition to continue with execution. Below table represents the possible outcomes -

JobCard COND ParameterContinue job execution
when condition is False
Terminate job when
when condition is true
COND=(code,GT)Code <= RC Code > RC
COND=(code,GE)Code < RCCode >= RC
COND=(code,EQ)Code ¬= RCCode = RC
COND=(code,LT)Code >= RCCode < RC
COND=(code,LE)Code > RCCode <= RC
COND=(code,NE)Code = RCCode ¬= RC

COND=(RC,RO,Stepname) -


COND=ONLY can be coded only at step level. COND= (RC, RO, Stepname) is used to execute the current step (where the COND parameter is coded) based on the respective step name return code. This COND parameter validates the respective step return code but not the previous step.

Syntax -

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

Example - Executing STEP3 based on the return code of STEP1.

//MTHEXMP1 JOB (META007),'PAWAN Y',NOTIFY=&SYSUID
//STEP1 EXEC PGM=P1 
//STEP2 EXEC PGM=P2 
//STEP3 EXEC PGM=P3,COND=(12,EQ,STEP1) 
//STEP4 EXEC PGM=P4

The below table shows the possible output comes -

STEP1 RC=12STEP3 will not execute
STEP1 RC<>12STEP3 should execute

Examples -


Scenario - COND=(4,GE)

//MTHEXMP1 JOB (META007),'PAWAN Y',NOTIFY=&SYSUID,COND=(4,GE)
//S1 EXEC PGM=P1 
//S2 EXEC PGM=P2 
//S3 EXEC PGM=P3
//S4 EXEC PGM=P4 

The COND parrameter applies to the each step like below -

//MTHEXMP1 JOB (META007),'PAWAN Y',NOTIFY=&SYSUID
//S1 EXEC PGM=P1,COND=(4,GE)
//S2 EXEC PGM=P2,COND=(4,GE)
//S3 EXEC PGM=P3,COND=(4,GE)
//S4 EXEC PGM=P4,COND=(4,GE)

Each step should complete its execution with the return code 0 to complete the job successfully. If any step return code is greater than 0, then the job execution terminates from there.