View previous topic :: View next topic
|
Author |
Message |
shiva001 Warnings : 1 New User
Joined: 19 Aug 2005 Posts: 13
|
|
|
|
I've heard about using 'IF THEN ELSE END-IF' in JCL.
Please let me know when & how to use them by giving small examples.
Thanks?ards,
Shiva |
|
Back to top |
|
|
Kevin
Active User
Joined: 25 Aug 2005 Posts: 234
|
|
|
|
There are plenty of examples shown in the JCL Reference Manual:
publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IEA2B660/17.1.10?SHELF=&DT=20050713232151&CASE=
Quote: |
17.1.10.1 Example 1
The following example shows the use of the alphabetic characters rather than special characters for comparison operators.
//IFBAD IF (ABEND | STEP1.RC > 8) THEN
or
//IFBAD IF (ABEND OR STEP1.RC GT 8) THEN
.
.
//IFTEST2 IF (RC > 4 & RC < 8) THEN
or
//IFTEST2 IF (RC GT 4 AND RC LT 8) THEN
|
Quote: |
17.1.10.2 Example 2
The following example shows a simple IF/THEN/ELSE/ENDIF statement construct without an ELSE statement.
//JOBA JOB ...
//STEP1 EXEC PGM=RTN
.
.
//IFBAD IF (ABEND | STEP1.RC > 8) THEN
//TRUE EXEC PROC=ERROR
//IFBADEND ENDIF
//NEXTSTEP EXEC PROC=CONTINUE
|
Quote: |
17.1.10.3 Example 3
The following example shows a simple IF/THEN/ELSE/ENDIF statement construct with a null ELSE clause.
//JOBB JOB ...
//STEP1 EXEC PGM=RTN
.
.
//IFBAD IF (ABEND | STEP1.RC > 8) THEN
//TRUE EXEC PROC=ERROR
// ELSE
//IFBADEND ENDIF
//NEXTSTEP EXEC PROC=CONTINUE
|
Quote: |
17.1.10.4 Example 4
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
|
Quote: |
17.1.10.5 Example 5
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 ...
|
Quote: |
17.1.10.6 Example 6
The following example shows two IF/THEN/ELSE/ENDIF statement constructs, one of which is nested in the ELSE clause of the other. The nested statements are indented so that they are easier to read.
//JOBE JOB ...
//PROC1 PROC
//PSTEPONE EXEC PGM=...
// PEND
//PROC2 PROC
//PSTEPTWO EXEC PGM=...
// PEND
//EXP1 EXEC PROC=PROC1
//EXP2 EXEC PROC=PROC2
//IFTEST4 IF (EXP1.PSTEPONE.RC > 4) THEN
//STEP1ERR EXEC PGM=PROG1
// ELSE
//IFTEST5 IF (EXP2.PSTEPTWO.ABENDCC=U0012) THEN
//STEP2ERR EXEC PGM=PROG2
// ELSE
//NOERR EXEC PGM=PROG3
//ENDTEST5 ENDIF
//ENDTEST4 ENDIF
//NEXTSTEP EXEC ...
|
|
|
Back to top |
|
|
|