z/OS MVS JCL Reference
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Example 5

z/OS MVS JCL Reference
SA23-1385-00

The following example shows nested IF/THEN/ELSE/ENDIF statement constructs with ELSE clauses. The nested statements are indented so that they are easier to read.
//JOBD      JOB   ...
//PROC1     PROC
//PSTEPONE  EXEC  PGM=...
//PSTEP11   EXEC  PGM=...
//PSTEP12   EXEC  PGM=...
//          PEND
//PROC2     PROC
//PSTEPTWO  EXEC  PGM=...
//          PEND
//EXP1      EXEC  PROC=PROC1
//EXP2      EXEC  PROC=PROC2
//IFTEST3   IF  (RC > 12) THEN
//STEP1BAD    IF  (EXP1.PSTEP11.RC > 12 OR EXP1.PSTEP12.RC > 12) THEN
//STEP1ERR    EXEC  PGM=ERRTN,PARM=(EXP1)
//            ELSE
//STEP2ERR    EXEC  PGM=ERRTN,PARM=(EXP2)
//END1BAD     ENDIF
//          ELSE
//NOPROB    EXEC  PROC=RUNOK
//ENDTEST3  ENDIF
//NEXTSTEP  EXEC  ...
Processing for the IF/THEN/ELSE/ENDIF construct named IFTEST3 is:
  1. If the relational-expression for IFTEST3 is true (the highest step return code for the job is greater than 12 at the point where this statement is being processed), the system processes the THEN clause of IFTEST3. It evaluates the relational-expression of the IF/THEN/ELSE/ENDIF construct named STEP1BAD.
  2. If the STEP1BAD relational-expression is true (the return code is greater than 12 for either of the two steps in procedure PROC1, which is invoked by step EXP1), the system processes the THEN clause of STEP1BAD. Step STEP1ERR invokes program ERRTN, passing EXP1 as a parameter.
  3. If the STEP1BAD relational-expression is not true, the system processes the ELSE clause for STEP1BAD. Step STEP2ERR invokes program ERRTN, passing EXP2 as a parameter.
  4. However, if the relational-expression for IFTEST3 is false, the system processes the ELSE clause. Step NOPROB invokes procedure RUNOK.
  5. Processing then continues with step NEXTSTEP.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014