COND Parameter

COND parameter is used to test return codes from previous job steps and determine whether to bypass or execute specified job steps. Return code is set based on the status of execution of a job. The return code can be a number between 0 (successful execution) to 4095 (non-zero shows error condition).

  • 0 = Normal – all OK
  • 4 = Warning – minor errors or problems.
  • 8 = Error – significant errors or problems.
  • 12 = Severe error – major errors or problems, the results should not be trusted.
  • 16 = Terminal error – very serious problems, do not use the results.

A job step execution can be controlled based on the return code of the previous step(s) using the COND parameter and IF-THEN-ELSE construct.

COND Parameter

A COND parameter can be coded in the JOB or EXEC statement of JCL. It is a test on the return code of the preceding job steps. If the test is evaluated to be true, the current job step execution is bypassed. Bypassing is just an omission of the job step and not an abnormal termination. There can be at most eight conditions combined in a single test.

Instead of coding a JOB statement COND parameter, code an EXEC statement COND parameter when you want to:

  • Specify different tests for each job step.
  • Name a specific step whose return code the system is to test.
  • Specify special conditions for executing a job step.
  • Bypass only one step. When a step is bypassed because of a JOB COND parameter, all following steps in the job are bypassed.

Note: Depending on the program invoked, a test showing that a return code from a step is zero is not sufficient to verify that the step did not fail. The system can fail a step (or job) even if the return code is

If you code the COND parameter on the JOB statement and on one or more of the job’s EXEC statements, and if a return code test on the JOB statement is satisfied, the job terminates. In this case, the system does not process any subsequent EXEC statement COND parameters.

If the tests on the JOB statement are not satisfied, the system then performs the return code tests on the EXEC statement. If a return code test is satisfied, the step is bypassed.

Syntax

COND=(rc,logical-operator)
or   (rc,logical-operator,stepname) 
or COND=EVEN or COND=ONLY

Rules:

  • One return code test is: (code,operator). 
  • You can omit the outer parentheses if you code only one return code test or only EVEN or ONLY. 
  • Specify up to eight return code tests. However, if you code EVEN or ONLY, specify up to seven return code tests. 
  • You can omit all return code tests and code only EVEN or ONLY. Place the EVEN or ONLY subparameters before, between, or after the return code tests.
  • Null positional sub-parameters of the COND parameter are invalid.
  • There can be multiple COND Parameter in JCL but a maximum of 8 COND parameter is allowed.

Here is the description of parameters used:

  • rc : This is the return code & is a decimal number from 0 through 4095.

Note: Specifying a decimal number greater than 4095 could result in invalid return code testing or invalid return codes in messages.

  • logical-operator : This 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).
  • stepname : This is the job step whose return code is used in the test. If you omit stepname, the code you specify is compared to the return codes from all previous steps. If the return code issued by any of those previous steps causes the test condition to be satisfied, the system evaluates the COND parameter as true and bypasses the job step.
  • EVEN: Specifies that this job step is to be executed even if a preceding job step abnormally terminated. When EVEN is coded, the system:
    • Does not test the return code of any steps that terminated abnormally.
    • Does test the return code of any steps that terminated normally. If none of the return code tests for these steps is satisfied, this job step is executed.
  • ONLY: Specifies that this job step is to be executed only if a preceding step abnormally terminated. When ONLY is coded, the system.
    • Does not test the return code of any steps that terminated abnormally.
    • Does test the return code of any steps that terminated normally. If none of the return code tests for these steps is satisfied, this job step is executed.
TypesCondition ExampleExplanation
Type 1COND=(0,EQ)Is return code 0 equal to the return code from the previous step? If this condition is true then bypass this step.
Type 2COND=(4,EQ,STEP10)Is return code 4 equal to the return code from the previous step? if this condition is true then bypass this step.
Type 3COND=EVENRun these steps even though, any of the previous steps has Abended.
Type 4COND=ONLYRun this step only if any of the previous steps has abended.

Example

Test in COND parameterExecute current stepBypass current step
COND=(code,GT)code <= RCcode > 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

Note: When the COND parameter does not name a previous step, the system tests all previous steps. If any test is satisfied, the system takes action on the current step, per the char above.

COND Parameter in JOB statement

When COND is coded in the JOB statement, the condition is tested for every job step. When the condition is true at any particular job step, it is bypassed along with the job steps following it. Following is an example:

 //TESTJB01 JOB CLASS=1,NOTIFY=&SYSUID,COND=(8,LE)
 //*
 //STEP01 EXEC PGM=PGM01  
 //* STEP01 executes without any test being performed.
 …..
 …..
 //STEP02 EXEC PGM=PGM02 
 //* STEP02 is bypassed, if RC of STEP01 is 8 or above. 
 //* Say STEP01 ends with RC4 and hence test is false. 
 //* So STEP02 executes and lets say it ends with RC16.
 ……..
 ……..
 //STEP03 EXEC PGM=PGM03
 //* STEP03 is bypassed since 8 < 16.

COND Parameter in EXEC statement

When COND is coded in EXEC statement of a job step and found to be true, only that job step is bypassed, and execution is continued from the next job step.

 //TESTJB02 JOB CLASS=2,NOTIFY=&SYSUID
 //*
 //STEP01 EXEC PGM=PGM01
 //* Assuming STEP01 ends with RC0.
 …..
 ….. 
 //STEP02 EXEC PGM=PGM02,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.

COND=EVEN

When COND=EVEN is coded, the current job step is executed, even if any of the previous steps abnormally terminate. If any other RC condition is coded along with COND=EVEN, then the job step executes if none of the RC conditions is true.

 //TESTJB03 JOB CLASS=3,NOTIFY=&SYSUID
 //*
 //STEP01 EXEC PGM=PGM01
 //* Assuming STEP01 ends with RC0.
 …..
 …..
 //STEP02 EXEC PGM=PGM02,COND=(0,EQ,STEP01)
 //* In STEP02, condition evaluates to TRUE and step bypassed.
 …..
 …..
 //STEP03 EXEC PGM=IEBGENER,COND=((10,LT,STEP01),EVEN)
 //* In STEP03, condition (10,LT,STEP01) evaluates to true,
 //* hence the step is bypassed.

COND=ONLY

When COND=ONLY is coded, the current job step is executed, only when any of the previous steps abnormally terminate. If any other RC condition is coded along with COND=ONLY, then the job step executes if none of the RC conditions is true and any of the previous job steps fail abnormally.

 //TESTJB04 JOB CLASS=4,NOTIFY=&SYSUID
 //*
 //STEP01 EXEC PGM=PGM01
 //* Assuming STEP01 ends with RC0.
  …..
  …..
 //STEP02 EXEC PGM=PGM02,COND=(4,EQ,STEP01)
 //* In STEP02, condition evaluates to FALSE, step is executed 
 //* and assume the step abends.
  …..
  …..
 //STEP03 EXEC PGM=IEBGENER,COND=((0,EQ,STEP01),ONLY)
 //* In STEP03, though the STEP02 abends, the condition 
 //* (0,EQ,STEP01) is met. Hence STEP03 is bypassed.

COND Parameter Examples

//STEP6 EXEC PGM=DISKUTIL,COND=(4,GT,STEP3)

In this example, if the return code from STEP3 is 0 through 3, the system bypasses STEP6. If the return code is 4 or greater, the system executes STEP6. Because neither EVEN nor ONLY is specified, the system does not execute this step if a preceding step abnormally terminates.

//TEST2 EXEC PGM=DUMPINT,COND=((16,GE),(90,LE,STEP1),ONLY)

The system executes this step ONLY if two conditions are met:

  1. A preceding job step abnormally terminated. 
  2. No return code tests are satisfied.

Therefore, the system executes this step only when all three of the following are true:

  • A preceding job step abnormally terminated.
  • The return codes from all preceding steps are 17 or greater.
  • The return code from STEP1 is 89 or less.

The system bypasses this step if any one of the following is true: • All preceding job steps terminated normally.

  • The return code from any preceding step is 0 through 16.
  • The return code from STEP1 is 90 or greater.
//STEP1 EXEC PGM=CINDY .
 .
//STEP2 EXEC PGM=NEXT,COND=(4,EQ,STEP1) .
 .
//STEP3 EXEC PGM=LAST,COND=((8,LT,STEP1),(8,GT,STEP2))

In this example, if STEP1 returns a code of 4, STEP2 is bypassed. Before STEP3 is executed, the system performs the first return code test. If 8 is less than the return code from STEP1, STEP3 is bypassed; or, restated, if the STEP1 return code is less than or equal to 8, STEP3 is executed. Because 4 is less than 8, STEP3 is executed.

The system does not perform the second return code test because STEP2 was bypassed.

//STP4 EXEC PROC=BILLING,COND.PAID=((20,LT),EVEN),  
// COND.LATE=(60,GT,FIND),
// COND.BILL=((20,GE),(30,LT,CHGE))

This statement calls cataloged or in-stream procedure BILLING. The statement specifies different return code tests for each of the procedure steps: PAID, LATE, and BILL. The system executes step PAID even if a preceding step abnormally terminates unless the accompanying return code is satisfied.

Read JCL blogs : Click Here. IBM Manual : Click Here

Scroll to Top