Defining Rules

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
rule
A 1- to 11-character user-assigned name for the rule. These names are specified in Aging Rule on the Aging Specifications and Aging Parameters panels.
desc
A 1- to 40-character string describing the rule. The string must be delimited by quotes. This is displayed on the rule name selection list. This is truncated if the length is greater than 40 characters.
avoid
List of date types. This list can include HOLIDAY, WEEKEND, and any user-defined date types.

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.

search
List of date types. This list can include HOLIDAY, WEEKEND, and any user-defined date types. Use the reserved word SAMEDOW to indicate same day of week processing. This processing is further governed by the specifications for SDOWACTION (see sdowaction).

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.

sdowaction
Action to be taken if SAMEDOW is specified on SEARCH. During execution of a rule with SAMEDOW specified on SEARCH, the initial step is to resolve the date forward or backward as determined by the DIR operand to the same day of the week as the original input date. Subsequent processing is determined by SDOWACTION. Specify:
MATCH
Adjusted date must land on the same day of the week as the original date. If the initial target date does not satisfy the other SEARCH and AVOID criteria, it is adjusted a week at a time until it does.
NEXTRULE
After date is adjusted to the same day of the week, if it does not conform to the other criteria, it is adjusted forward to the next date that satisfies the other SEARCH and AVOID criteria.
PREVRULE
After date is adjusted to the same day of the week, if it does not conform to the other criteria, it is adjusted backward to the previous date that satisfies all of the other SEARCH and AVOID criteria.

If not specified, MATCH is the default.

dir
Specify how the date is to be adjusted if the calculated date does not meet the criteria of AVOID and SEARCH. Specify:
CLOSEST
Date is adjusted to the closest date meeting the SEARCH criteria not included in the AVOID list. If the number of days from previous and next is the same, the next date is assumed. However, you can override this default by specifying the MATCH operand on the RULEDEF=START statement.
PREVIOUS
Date is adjusted to the closest previous date not included in the AVOID list and included in the SEARCH list, if defined.
NEXT
Date is adjusted to the closest next date not included in the AVOID list and included in the SEARCH list, if defined.

If not specified, NEXT is the default.

RULEDEF Examples

The following examples demonstrate using RULEDEF to define the rules.

They provide examples for using each of the operands.

  • Avoid Non-Workdays

    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
    
  • Ensure Payday is a Workday

    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
    
  • Ensure Same Day of the Week

    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
    
  • Handle Start-of-Quarter

    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