JCLintermediate

Conditional Step Execution: COND and IF/THEN/ELSE

Control whether a job step executes based on prior step return codes, using both the legacy COND parameter and the more readable IF/THEN/ELSE construct.

Batch jobs frequently need to skip a step if an earlier step failed, or run a cleanup step only on failure — JCL provides two mechanisms for this, and knowing both (plus why one replaced the other) is a strong interview signal. COND is the older, notoriously confusing parameter; IF/THEN/ELSE/ENDIF is the modern, far more readable replacement introduced in later JCL versions.

COND is a note that says 'do NOT proceed unless this comparison is false' pinned to the door — it works, but you have to read it twice to be sure which way it swings; IF/THEN/ELSE is a green light and a red light, exactly as intuitive as they look.

Key Concepts

1
COND=(code,operator) on an EXEC statement is evaluated as 'bypass this step if the condition is true' — which is backwards from how most people intuitively read it the first time, and is exactly why COND has a reputation for tripping up even experienced programmers. COND=(4,LT) means 'skip this step if 4 is less than the prior step's return code,' which reads awkwardly and is easy to get inverted.
2
IF/THEN/ELSE/ENDIF reads like a normal programming conditional: IF RC-STEP1 > 4 THEN, followed by the steps to run in that branch, ELSE for the alternative, ENDIF to close it. It can reference RC (return code) or ABEND conditions of named prior steps directly, and supports nesting, which COND fundamentally cannot do cleanly.
3
Interviewers sometimes present a COND clause and ask you to translate it into IF/THEN/ELSE (or vice versa) specifically to test whether you understand COND's inverted logic rather than just recognizing the syntax — this is one of the more reliable ways to separate candidates who've memorized examples from those who actually understand step-level flow control.