%%IF, %%ELSE, and %%ENDIF control statements provide the AutoEdit facility with Boolean "IF" logic capability. These statements, in conjunction with %%GOTO and %%LABEL control statements, permit branching based on submission time criteria. Job steps, DD statements, and so on are easily excluded or included.
The format of %%IF, %%ELSE, %%ENDIF statements is:
|
|
|
|
|
where:
The format of a conditional-expression is:
operand operator operand
where:
Operators that end with the pound sign (#) are used for numerical comparisons, while operators without the pound sign (#) are used for string comparisons.
In string comparisons, operands are compared as character strings from left to right.
In numeric comparisons, the operands must represent valid arithmetic values.
When numeric operators are used, the following requirements apply to the operands:
1. Arithmetic values can have leading signs (+ or -). For example: "+12", "-00034".
2. Arithmetic values can contain decimal points. For example: "1.5", "+2.25", "-3.01".
3. Leading zeros and blanks are ignored. A leading sign, if specified, must precede any leading zeros. For example: "+0001" but not "000+1.
4. The following maximum length limitations apply: 39 digits before a decimal point and 40 digits after a decimal point.
Table 257 Examples of conditional-expressions
Statement |
Truth value |
---|---|
%%IF 01 EQ# 1 |
TRUE |
%%IF 01 EQ 1 |
FALSE |
%%IF 91 GT 1000 |
TRUE |
%%IF 91 GT# 1000 |
FALSE |
%%IF 91 GT# 10.00 |
TRUE |
%%IF 1000 GT# 91 |
TRUE |
%%IF -91 GT# -1000 |
TRUE |
%%IF 91 GT# ABC |
Syntax error |
If an operand contains AutoEdit terms, they are resolved into a character string before the conditional expression is analyzed.
An operand must not resolve to a null value (as in CLISTs). If it is possible that an operand resolves to a null value, place a character before the first and second operands in a way that would not affect the comparison. For example, if %%A and/or %%C in the statement:
%%IF %%A GT %%C
might resolve to null, use a substitute expression such as:
%%IF B%%A GT B%%C
An %%IF expression must be terminated with an %%ENDIF statement. If an %%IF expression is not terminated in this way, an %%ENDIF statement is implied as the last statement in the member.
The %%ELSE statement is optional.
The AutoEdit facility performs a validity check on %%IF and %%ENDIF control statement pairs in JCL members. If a %%IF control statement is detected, which is not closed by %%ENDIF control statement, it will be automatically closed at end of member and a warning message is issued.
When the %%IF expression is true, all JCL statements (including non-AutoEdit statements) between the %%IF expression and its %%ELSE statement (or its matching %%ENDIF statement when no %%ELSE statement is present) are submitted by Control-M provided that all AutoEdit variables are resolved.
When the %%IF expression is not true and an %%ELSE statement exists, only statements between the %%ELSE statement and the matching %%ENDIF statement are submitted.
Using the AutoEdit facility, several %%IF statements in one JCL member can be combined, so that a number of jobs defined in the member can be combined into one job, which can be submitted by Control-M.
%%IF statements can be nested.
The following logically connected statements may be specified on one line:
Example
|
Up to 100 nested %%IF statements can be specified.
Parent Topic |