How to Use JCL Cond Parameters

How to use JCL Cond Parameters to skip a step in a Job

Cond Parameters are used in Job steps to route the job execution of each steps or a particular step. For example if you want to skip a particular step based on previous steps outcome, using a COND parameter is a good solution. COND Parameters can be coded at step level or the job levels and based on the return codes the execution can be altered.

COND Parameters comes handy when there are dependent job steps are present and they are interrelated. If a COND parameter is coded at JOB level, then the condition will be checked for every step except the first step. Return code of the predecessor step will be evaluated for the condition check.

Is there any alternative for COND Parameter

How to Use JCL Cond Parameters
How to Use JCL Cond Parameters

Instead of COND parameter you can also use “If then else” in JCL . If-then-else statements has its own advantage as it’s more controlled and gives additional flexibility on structuring the job execution.

COND Syntax in JCL

Below is the basic syntax of COND parameters in JCL.

COND=(Return Code ,logical-operator)
or
COND=(Return Code ,logical-operator, step name)
or
COND=EVEN
or
COND=ONLY

Logical Operator can be GT (Greater Than), GE (Greater than or Equal to), EQ (Equal to), LT (Lesser Than), LE (Lesser than or Equal to) or NE (Not Equal to).

Sample JCL using IF-THEN-ELSE in JCL

//JOBSAMP JOB CLASS=6,NOTIFY=&SYSUID,COND=(5,LE)
//*
//STEP010 EXEC PGM=STEP100
//* STEP010 executes without any test being performed.

//STEP020 EXEC PGM=STEP200
//* STEP020 is bypassed, if RC of STEP010 is 5 or above.
//* Say STEP010 ends with RC4 and hence test is false.
//* So STEP020 executes and lets say it ends with RC16.

//STEP030 EXEC PGM=SORT
//* STEP030 is bypassed since 5 <= 16.

Sample JCL using COND Parameter at Step Level in JCL

//JOBSAMP JOB CLASS=6,NOTIFY=&SYSUID
//*
//STEP01 EXEC PGM=SORT
//* Assuming STP01 ends with RC0.

//STEP02 EXEC PGM=MYCOBB,COND=(0,EQ,STEP01)
//* In STEP02, condition evaluates to TRUE and step bypassed.

//STEP03 EXEC PGM=IEBGENER,COND=((10,LT,STEP01),(10,GT,STEP02))
//* In STEP03, first condition fails and hence STEP03 executes.
//* Since STEP02 is bypassed, the condition (10,GT,STEP02) in
//* STEP03 is not tested.

How to use COND parameter in JCL?

The COND parameter in JCL (Job Control Language) allows you to specify conditions that control the execution of subsequent job steps. It is used to define dependencies between job steps and determine whether a particular step should be executed based on the outcome of a previous step. Here’s how you can use the COND parameter in JCL:

  1. Understanding the COND syntax: The COND parameter follows a specific syntax: COND=(condition). The condition consists of one or more tests separated by logical operators (AND, OR, or NOT). Each test evaluates the status of a prior job step and determines whether the subsequent step should execute. The syntax for a test is stepname.rc=condition, where “stepname” refers to the name of the prior step, “rc” stands for return code, and “condition” specifies the condition to be met.
  2. Setting up a simple COND condition: Let’s assume you have two job steps, STEP1 and STEP2, and you want to execute STEP2 only if STEP1 completes successfully. You can set up the COND parameter for STEP2 as follows: //STEP2 EXEC PGM=YOURPGM,COND=(STEP1.RC=0)In this example, STEP2 will only execute if the return code (RC) of STEP1 is 0, indicating successful completion. If the return code is anything other than 0, STEP2 will be bypassed.
  3. Using logical operators: You can use logical operators (AND, OR, NOT) to combine multiple conditions and create more complex dependencies. For instance, if you want to execute STEP3 only if both STEP1 and STEP2 complete successfully, you can use the AND operator as follows: //STEP3 EXEC PGM=YOURPGM,COND=((STEP1.RC=0) AND (STEP2.RC=0))In this case, STEP3 will only execute if both STEP1 and STEP2 have a return code of 0.
  4. Using NOT operator: The NOT operator allows you to negate a condition. For example, if you want to execute STEP4 only if STEP1 fails (i.e., return code is not 0), you can use the NOT operator as follows: //STEP4 EXEC PGM=YOURPGM,COND=(STEP1.RC<>0)Here, STEP4 will execute only if the return code of STEP1 is not equal to 0.

Remember that the COND parameter can be specified on any executable job step in JCL, allowing you to define complex dependencies and control the flow of your job. Make sure to review the documentation or consult with your system administrator to ensure you’re using the COND parameter correctly and effectively in your specific mainframe environment.

Leave a Comment