After you have defined the entries in the table for each declared type, you define rules to be applied when an aged date must or must not fall on the day defined by a date type.
You can define any number of rules. For each rule, the parameters can be specified in any order.
The syntax for a rule statement is:
RULEDEF RULE=rule,
DESC='string'
AVOID=avoid,
SEARCH=search,
SDOWACTION=sdowaction
DIR=dir
If the calculated date falls on a day defined by one of the listed date types, search for the next or previous day that is not defined by a listed type.
(Next or previous is defined by the DIR parameter. If not specified, next is the default.)
Use a comma, with no intervening spaces, to list multiple date types as in HOLIDAY,WEEKEND. Enclose the list in parentheses.
The calculated date must be defined by one of the listed date types. If AVOID is also specified, the calculated date must be included in the SEARCH list and not included in the AVOID list.
Use a comma, with no intervening spaces, to list multiple date types as in HOLIDAY,WEEKEND. Enclose the list in parentheses.
If not specified, MATCH is the default.
If not specified, NEXT is the default.
The following examples demonstrate using RULEDEF to define the rules.
They provide examples for using each of the operands.
To adjust a date to the next workday, use AVOID to list the date types and DIR to specify the direction. That is, using the following definition, if the aged date falls on a holiday or weekend, it is adjusted. For example, if Christmas falls on a Friday, the date is adjusted to the next workday, Monday.
RULEDEF RULE=NEXTWORKDAY,AVOID=(WEEKEND,HOLIDAY),DIR=NEXT
To ensure that the adjusted date is a payday and if not, adjust the date to the previous payday, specify SEARCH to ensure that only paydays are the target and DIR to specify the direction of the adjustment. For example, using the following definition, if the aged date is not a payday, the date is adjusted to the previous payday.
RULEDEF RULE=PAYDAY,SEARCH=(PAYDAY),DIR=PREVIOUS
To ensure that the adjusted date falls on the same day of the week as the original input date, specify SEARCH as SAMEDOW. For example, if the aged date does not fall on the same day of the week, it is adjusted (by default) to the next occurrence of the same day of the week.
RULEDEF RULE=NEXTSAMEDOW,SEARCH=(SAMEDOW),DIR=NEXT
To ensure that the adjusted date is the start of a quarter, you need to specify SEARCH to limit the date type to QUARTER.
RULEDEF RULE=CLOSSTRTQTR, X
SEARCH=QUARTER, X
DIR=CLOSEST