COND Parameter Examples in JCL

COND PARAMETER EXAMPLES in JCL

COND parameter in JCL is to execute the JOB steps conditionally. For example if in a JOB, the first Step Unloads the data from a DB2 table and step02 takes that Unload file and filters it using sort and step03 has a cobol db2 program which uses the sort output as its input.
So all the steps in this job are interdependent thus the return codes of preceding steps should be verified before executing that to get the proper output.So COND parameter in JCL fulfills the above requirement.
It validates the return code from previous steps and if it is satisfied then bypasses that step from execution and terminates the job if there is no special COND parameters in the succeeding JOB steps. If it finds any Special COND parameters like ONLY or EVEN, then system executes those steps.

Common Syntax:

COND=(<rc>,<operator>)
– rc can be anything from 0 to 4095
– Operator can be EQ,NQ,GT,GE, LT, LE

EQ –> Equals to
NE –> Not Equal to
GT –> Greater than
GE –> Greater Than or Equals to
LT –> Less than
LE –> Less than or Equals to

Different scenarios:

– Bypassing a Step using COND parameter is not same as abnormal termination of a JOB due any abend.

– It can be given at the JOB level where it applies to all the steps in that JOB. If any of the Steps return code satisfies the JOB COND parameter, then the job gets terminated in that step itself. It does not execute succeeding steps.

– It can be coded at step level. If coded, it applies only to that EXEC where it validates its preceding steps return code. IF any of the preceding steps RC is satisfied, then it bypasses that step and terminates the job.

– While giving at step level, a stepname can be included in the COND so that it validates the return code against that step’s return code.

– Can be given both at JOB level & step level. In this case system evaluates the the job level parameter first and if it meets the condition then the job terminates without checking the step level parameter. In case the JOB level parameters does not meets the condition then Step level ones gets evaluated.

– Multiple COND parameters can be coded, where it evaluates all the COND parameters and any one is satisfied, it terminates the JOB. System considers multiple JOB parameters with an OR condition.

– EVEN & ONLY are the special parameters which are applicable to Step level.

– COND=EVEN is to tell the SYSTEM that to execute that step even though any of the previous steps abnormally terminated.

– COND=ONLY is to tell the systems that to execute that step ONLY if any of the previous steps abnormally terminated. This is useful when there is any separate routine to log the error details
in case of Abends.

The difference Between EVEN and ONLY is, Even executes irrespective of the previous steps return codes. That steps gets executed in case of normal return codes and also in case of abends. But in case of ONLY, the step gets executed in the ABEND case only.

Examples of COND Parameter in JOB card and EXEC:
  1. COND=(0,NE)
    Bypassed if the Return code of any previous steps is not equal to ‘0’. If RC is 4 from the previous step, then it gets bypassed.
  2.  To check any specific step return code
    COND=((0,NE,STEP01) – This validates the return code of Step01 and if it Zero then it executes that step other wise skips the job execution.
  3.  COND=(0,EQ)
    This is opposite to the example 1. Here it bypasses the step if the RC from any of the previous steps are equal to ‘0’. It executes when RC is greater than Zero.
  4.  What is the COND parameter if a Step should not be executed in any condition.
    a)(4095,GT)
    Here 4095 is the maximum allowable return code in JCL. So with this condition it bypasses that step for all the return         codes that are greater than 4095.                                                                           b) (0,LE) –>  Here, if ‘0’ is Less than or Equals to Return code then that step is bypassed but all the return codes would be Zero or greater so this condition is always satisfied and the step never executes.
  5.  What is the COND parameter to always execute a step.                                                                          a)  COND=(4095,LT)                                                                                                                                b) COND=(0,GT), It checks ‘0’ is greater than the return code value or not means it checks whether the Return code is less than ‘0’ or not. As always return code equal to or greater than Zero, this condition is always not satisfied and the step gets executed always.
  6.   Execute a Step based on the return code of a particular step.
    This can be coded by including the step name in the after the Operator as shown below. IN this case the rerun code of step02 only validated.
    (08,GT,SETP02)
  7.  Multiple COND parameters

COND=(04,EQ,STEP01),(08,LT,STEP02)

Systems evaluates both the parameters and if any one is satisfied, it bypasses that.

Considerations:

1. When JOBLIB and ONLY parameter is specified, the Unit & Volume parameters of the JOBLIB are not passed to the next step.

2. The COND on the first step of a JOB is always evaluated as false as it does not have any preceding steps to evaluate. So the first step gets executed always.

3. In case of RESTART where the restarted step has a COND value, then the system considers that step as first step and evaluates it as FALSE so that it gets executed.

Overriding COND parameter:

– COND parameter coded on JOB card gets evaluated first and if it is satisfied, the job gets terminated. Otherwise the step level  parameter gets evaluated.

– Can be overridden from a JOB step that is executing the proc as below

//JOB001 JOB …
//…
//JOBSTP01 EXEC PROC01, COND.PRCSTP01=(4,LT)

COND parameter specified at PRCSTP01 of PROC01 gets overridden with (4,LT)

 

There are many resources and materials that IBM has provided on this topic.  Below are the few references where you can find more detailed information of this topic.

IBM Source-1

IBM Source-2

Examples from IBM

 

If you find any wrong information in the above topic, Please post it via comments so that, we will check and correct it if required.

Leave a Reply

Your email address will not be published. Required fields are marked *