The following example shows a simple IF/THEN/ELSE/ENDIF statement
construct with an ELSE clause.
//JOBC JOB ...
//STEP0 EXEC PGM=RTN1
.
.
//IFTEST2 IF (RC > 4 & RC < 8) THEN
//* *** WARNING CONDITION REPORTING GROUP ***
//STEP1 EXEC PGM=IEFBR14
//REPORT EXEC PROC=REPTRTN
//* *** WARNING CONDITION REPORTING GROUP END ***
// ELSE
//ERRORSTP EXEC PROC=ERRORTN
//ENDTEST2 ENDIF
//NEXTSTEP EXEC PROC=CONTINUE
Processing for this IF/THEN/ELSE/ENDIF statement construct is:
- If the relational-expression for the IF/THEN statement construct
named IFTEST2 is true (the highest step return code for the job is
greater than 4 and less than 8 at the point when this statement is
being processed), the system processes the THEN clause. The system
executes program IEFBR14 and procedure REPTRTN on EXEC statements
STEP1 and REPORT.
- Otherwise, the relational-expression for IFTEST2 is false and
the system processes the ELSE clause (procedure ERRORTN on EXEC statement
ERRORSTP).
- Processing then continues with procedure CONTINUE on step NEXTSTEP.