EXEC Statement COND Parameter  (text pg 87-94)

Assignment 4 used the parameter COND=EVEN on an EXEC statement to run a step even when a preceding step abended.

But the COND parameter actually has a more general form:

   COND=(number,operator[,stepname])

   (The square brackets around ",stepname" mean that parameter can be omitted; see below.)

The operator above is used to compare the number to the return code of the named step, and if the result of that comparison is TRUE, the conditioned step will be bypassed (AKA "skipped").

Thus COND specifies the results for which to not run a step, or in other words, the conditioned step will run unless the condition is true.

The comparison operator can be any one of the following:

  • NE for not equal
  • EQ for equal
  • LT for less than
  • GT for greater than
  • LE for less than or equal
  • GE for greater than or equal

Here’s a simple 2-step example:
   //STEP1 EXEC PGM=UPDATE
   //STEP2 EXEC PGM=FIXIT,COND=(0,NE,STEP1)

In this example the number 0 is compared using the operator not equal to the return code from the program UPDATE executed in STEP1, and unless zero does not equal that return code, STEP2 will be run.

i.e. STEP2 won’t be run if STEP1 returned a non-zero return code.

Omitted Step Name

If the step name is omitted, the number is to be compared to the return codes from all previous steps, and if any of those results is TRUE, the conditioned step is to be skipped.

e.g. if any step had a non-zero return code, STEP2 below will not be run:
     //STEP2 EXEC PGM=FIXIT,COND=(0,NE)

Multiple Tests

Multiple tests can also be combined in a COND stmt (with an implied OR), to skip execution as a result of the R/Cs from multiple steps:
    //STEP3 EXEC PGM=REPORT,COND=((0,NE,STEP1),(4,LT,STEP0))

Here STEP2 will be skipped if either STEP1 returned a non-zero code, or if 4 is less than the return code from STEP0.

But if the listed conditions are always combined with an "OR" operator, what do you do if you want to combine them with an "AND"?

Earn a 2% Credit

You can earn a credit of up to 2% of your final mark by participating in a discussion about the COND statement.

Tell us what the following COND parameters would be, and say when you think those parameter might be useful in real jobs:

  • A COND parameter for STEP3 above to run unless STEP1 returns a non-zero code and if 8 is less than the return code from STEP0.
  • A COND parameter to run a step unless any preceding steps returns a code of 8 or higher.
  • A COND parameter to run a step unless none of the preceding step returns a zero code.

Post your comments for everyone to see by selecting Compose Message after clicking on Discussions in the ACTION MENU at the top of this page, or by clicking on Communications Tools on the Home page and then on DISCUSSIONS.


Click on Next in the above ACTION MENU> to learn about parameters in JCL PROCs.