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
DIRparameter. 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 wordSAMEDOWto indicate same day of week processing. This processing is further governed by the specifications forSDOWACTION(seesdowaction).The calculated date must be defined by one of the listed date types. If
AVOIDis also specified, the calculated date must be included in theSEARCHlist and not included in theAVOIDlist.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
SAMEDOWis specified onSEARCH. During execution of a rule withSAMEDOWspecified onSEARCH, the initial step is to resolve the date forward or backward as determined by theDIRoperand to the same day of the week as the original input date. Subsequent processing is determined bySDOWACTION. 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
SEARCHandAVOIDcriteria, 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
SEARCHandAVOIDcriteria. 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
SEARCHandAVOIDcriteria.
If not specified,
MATCHis the default.
- dir
- Specify how the date is to be adjusted if the calculated date
does not meet the criteria of
AVOIDandSEARCH. Specify:CLOSEST- Date is adjusted to the closest date meeting the
SEARCHcriteria not included in theAVOIDlist. 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 theMATCHoperand on theRULEDEF=STARTstatement. PREVIOUS- Date is adjusted to the closest previous date not included in
the
AVOIDlist and included in theSEARCHlist, if defined. NEXT- Date is adjusted to the closest next date not included in the
AVOIDlist and included in theSEARCHlist, if defined.
If not specified,
NEXTis 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
AVOIDto list the date types andDIRto 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
SEARCHto 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
SEARCHasSAMEDOW. 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
SEARCHto limit the date type toQUARTER.RULEDEF RULE=CLOSSTRTQTR, X SEARCH=QUARTER, X DIR=CLOSEST