|
Back Issue
|
JCL IF Statement Revisited
The condition portion of this statement is somewhat underdocumented.
It can consist of an expression which evaluates to 'TRUE' or 'FALSE'
or a comparison of two values. The two values being compared must be of the same type:
- a numeric value 0-4095 (something which looks like a return code).
This includes the RC operator.
- values of the form Udddd where dddd is a decimal number 0001-4095
or Sxxx where xxx is a hexadecimal value in the range 001-FFF
(something which looks like an abend code). This includes the ABENDCC operator.
- values 'TRUE' or 'FALSE'. This includes the RUN or ABEND operator.
The operators can:
- be specific to a step, e.g. ABEND.STEP1 which is set depending on whether or not STEP1 abended OR
- apply to the whole job: ABEND - did any step abend?
Here is an example of what can be done:
// SET ABCLEAN='TRUE'
//COPY EXEC PGM=MYPGM
....
// IF (ABEND = &ABCLEAN | COPY.RC > 8) THEN
//FINAL EXEC PGM=CLEANUP
....
// ELSE
//CLEAN EXEC PGM=LASTPGM
....
// ENDIF
//
As it stands, the cleanup program runs if any step abends or the return code
from the COPY step is greater than 8. However, if the setting for ABCLEAN
is changed to FALSE, then the cleanup program will not run if any step
abends.
Another possibility is:
....
// SET RUNFIN='FALSE'
// IF &RUNFIN THEN
//FINAL EXEC PGM=CLEANUP
....
// ENDIF
In this example, the final step will not execute. The setting for RUNFIN could be altered to TRUE to change
this behaviour. Note that an IF statement or COND parameter test does not prevent the first step in a job from running.
Feedback
Comments or suggestions can be
sent to the author.
Last Month's Topic