In general, the syntax of the DIF rules language is obvious. There are some special constructs, such as the DEFPOOL statement, which specifies the characteristics of a disk or tape pool, and the DEFENV statement, which is used to modify defaults for the types of processing that may take place at various points during dataset allocation or space error recovery. However, most processing takes place as result of a series of IF / THEN / ELSE statements which occur following a DEFRULE statement. DEFRULE provides the name for a rule. One or more IF / THEN / ELSE statements follow a DEFRULE statement. These statements conclude with an action clause, usually a SET statement of the form SET DISKPOOL=poolname to assign the dataset to an ACC allocation pool or SRS recovery pool. Complete syntax can be found in the Dynamic Install Facility User’s Guide and the Allocation Control Center / Space Recovery System User’s Guide.
Rules language architecture
The sample rule member shown is divided into a number of sections. In reality, most statements, such as DEFFILT (FILTLIST), DEFPOOL, and DEFMSG may be placed anywhere within the rules. However, the sequence of statements in the sample rule member is similar to that widely used by SyncsortTM Storage Management customers and provides a proven, easy-to-understand view of the rules logic. Also, as the rules language is executed top-to-bottom through the rules (DEFRULE statements) and the IF / THEN / ELSE statements that occur under the DEFRULEs, it is best to place the rules which apply to all datasets first, followed later by more narrowly-targeted rules, as shown in the sample.
Comments, readability, and maintainability
Although the DIF rules language is mostly free-form, it is of course best to follow standard coding conventions. That is, indentation and comments always make for easier-to-read and more-maintainable code. Comments in the DIF rules language are indicated by either an asterisk in the first column, which indicates that the entire statement following is a comment, or by a /* */ pair, which encloses the comment.
Blank lines are ignored by DIF rules processing, so they may be used as needed to provide clarity.
Continuation
Statements may be continued on the next line by breaking at a comma and continuing the statement on the next line, as shown in the example below. The quoted text fields in DEFMSG statements must be continued by placing a plus (+) sign at the end of the statement and continuing with the rest of the statement, in quotes, on the next line, as shown in the second example.
DEFPOOL PRDPOOL3 VOLSER=(PRD001,PRD002,PRD003,
PRD004,PRD005,PRD6*)
DEFMSG MYMSG1 THIS IS A LONG MESSAGE +
THAT IS CONTINUED ON A SECOND LINE
Nested IF’s
The DIF rules language allows nested IF statements. However, any nested IF must be contained within a DO-END pair, or the results will be unpredictable. The example below shows a valid nested IF. There is no limit to the amount of nesting, but more than 2 or 3 levels is difficult to understand and likely to lead to logic errors.
DEFRULE SOMERULE
IF &QUAL2 = PROD THEN DO
END
IF &JOBNAME = ABC*
THEN SET &DISKPOOL = PRODPOOL
ELSE DO
IF &JOBNAME = ABC*
THEN SET &DISKPOOL = TESTPOOL
END
Flow of control
There are a few important points to remember about the flow-of-control through the DIF rules language:
- The flow-of-control is from top-to-bottom unless altered by a CONTINUE parameter.
- Rule processing is terminated (the rules are exited) whenever the first IF / THEN / ELSE condition is satisfied, unless a CONTINUE parameter is present on the DEFRULE or on the THEN or ELSE clause.
- Once a pool has been assigned to a dataset via a SET DISKPOOL= clause, the rules are not executed again for that dataset unless RULES(ALWAYS) is specified on the DEFENV statement.
Examples of continue parameter
In order to continue rule processing after a successful IF / THEN / ELSE statement, the CONTINUE parameter must be present. It may be present on the rule definition (the DEFRULE statement), or it may be specified as part of the IF / THEN / ELSE, as shown in the examples below.
DEFRULE SKIPRULE CONTINUE(NEXTIF)
IF &DDNAME = (SORTOU*, SORTOF*) THEN SET &SKIP_EXCP = YES
DEFRULE RLSERULE IF &ENV = DD
&DSORG = (PS,'')
&DISP1 = NEW
THEN SET &RLSE = YES
CONTINUE SCANNING AT NEXTRULE