Previous Topic

Next Topic

Book Contents

Book Index

%%IF, %%ELSE, %%ENDIF

%%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:

%%IF conditional-expression

statements

[%%ELSE]

statements

%%ENDIF

where:

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

%%IF expression
%%IF expression
       statements
       .
       [ %%ELSE ]
       .
%%ENDIF
%%ELSE
%%IF expression
       statements
       .
       [ %%ELSE ]
       .
%%ENDIF
%%ENDIF

Up to 100 nested %%IF statements can be specified.

Parent Topic

Control Statements