The COND parameter is often one of the most confusing JCL concepts for beginners because its logic works in a somewhat counterintuitive way.
When you code COND=(0,NE) on a job step, the condition is evaluated against the return codes of all previous steps.
- If any previous step returns a code other than 0, the condition (0,NE) evaluates to true, and the current step is bypassed (FLUSHED).
- If all previous steps return 0, the condition evaluates to false, and the current step executes normally.
In simple terms, COND=(0,NE) means "Execute this step only if all preceding steps completed successfully with RC=0."
Example
//SYSPRINT DD SYSOUT=
//SYSIN DD
SET MAXCC=4
//*
//STEP2 EXEC PGM=IEFBR14
//*
//STEP3 EXEC PGM=IEFBR14,COND=(0,NE)
//*
Execution Results :
Step Name | Return Code |
STEP1 | 04 |
STEP2 | 00 |
STEP3 | FLUSH |
Why Was STEP3 Flushed?
- STEP1 ended with RC=04.
- Since 04 is not equal to 0, the condition COND=(0,NE) becomes true.
- As a result, STEP3 is skipped (FLUSHED).
Even though STEP2 completed with RC=00, JCL evaluates the condition against all preceding steps, not just the immediately prior step. Because STEP1 returned a non-zero code, STEP3 does not execute.
Key takeaway: COND=(0,NE) is commonly used to ensure a step runs only when all earlier steps have completed successfully with a return code of zero.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.