Examples of IF/THEN/ELSE/ENDIF statement construct

Example 1: This example tests the return code for a step.
//RCTEST     IF    (STEP1.RC GT 20|STEP2.RC = 60)   THEN
//STEP3      EXEC PGM=U
//ENDTEST    ENDIF
//NEXTSTEP   EXEC  
The system executes STEP3 if

If the evaluation of the relational expression is false, the system bypasses STEP3 and continues processing with step NEXTSTEP.

Example 2: This example tests for an abend condition in a procedure step.
//ABTEST     IF     (STEP4.LINK.ABEND=FALSE)   THEN
//BADPROC    ELSE
//CLEANUP    EXEC   PGM=ERRTN
//ENDTEST    ENDIF
//NEXTSTEP   EXEC  

The relational expression tests that an abend did not occur in procedure LINK, called by the EXEC statement in STEP4. If the relational expression is true, no abend occurred. The null THEN statement passes control to step NEXTSTEP. If the relational expression is false, an abend occurred. The ELSE clause passes control to the program called ERRTN.

Example 3: This example tests for a user abend completion code in the job.
//CCTEST   IF   (ABENDCC = U0100)   THEN
//GOAHEAD  EXEC  PGM=CONTINUE
//NOCC     ELSE
//EXIT     EXEC  PGM=CLEANUP
//         ENDIF  

If any job step produced the user abend completion code 0100, the EXEC statement GOAHEAD calls the procedure CONTINUE. If no steps produced the completion code, the EXEC statement EXIT calls program CLEANUP.