In this Control-M/Analyzer solution, the rule
In this rule, you will learn how to refer to and access various generations of data from the database.
Opening Rule ARWARN05
If you are not familiar with how to select a rule for browsing, review the instructions at the beginning of the discussion of rule ARWARN02 in Problem 2.
The rule consists of the following three blocks:
Figure 87 Rule ARWARN05
LIBRARY : CTB.PROD.RULES RULE : ARWARN05
COMMAND ===> SCROLL===> CRSR
+---------------------------------- BROWSE -----------------------------------+
| OWNER M66 GROUP INTRAC |
| UPDATED 11/09/99 - 11:53:49 BY M66 |
| DESC CHECK WEEKLY SALES AND COST OF SALES AMOUNTS |
| OPTIONS |
| =========================================================================== |
| EXECUTE INIT UPON C |
| ON DATA |
| LABEL: SETVARS |
| ALWAYS |
| DO SET = WEEKSALES01=0 C |
| DO SET = WEEKSALES02=0 C |
| DO SET = WEEKSALES03=0 C |
| DO SET = WEEKCOST01=0 C |
| DO SET = WEEKCOST02=0 C |
| DO SET = WEEKCOST03=0 C |
| DO SET = CTR1=0 C |
| DO SET = BLANK=' ' C |
| =========================================================================== |
| EXECUTE ACCUMSLS UPON C |
| ON DATA |
PLEASE FILL IN RULE DEFINITION. 15.43.46
Figure 88 LABEL ACCUM in the ACCUMSLS ON Block
LIBRARY : CTB.PROD.RULES RULE : ARWARN05
COMMAND ===> SCROLL===> CRSR
+---------------------------------- BROWSE -----------------------------------+
| LABEL: ACCUM |
| ALWAYS |
| DO SET = WEEKSALES01=WEEKSALES01 + DB_INVAMT01@G%%CTR1 C |
| DO SET = WEEKSALES02=WEEKSALES02 + DB_INVAMT02@G%%CTR1 C |
| DO SET = WEEKSALES03=WEEKSALES03 + DB_INVAMT03@G%%CTR1 C |
| DO SET = WEEKCOST01=WEEKCOST01 + DB_COST01@G%%CTR1 C |
| DO SET = WEEKCOST02=WEEKCOST02 + DB_COST02@G%%CTR1 C |
| DO SET = WEEKCOST03=WEEKCOST03 + DB_COST03@G%%CTR1 C |
| DO SET = CTR1=INT(CTR1+1) C |
| IF CTR1<5 C |
| DO GOTO LABEL ACCUM |
| =========================================================================== |
| EXECUTE CHECK UPON C |
| ON DATA |
| ALWAYS |
| DO SET = MARGIN1=(WEEKSALES01-WEEKCOST01)/WEEKSALES01 C |
| DO SET = MARGIN2=(WEEKSALES02-WEEKCOST02)/WEEKSALES02 C |
| DO SET = MARGIN3=(WEEKSALES03-WEEKCOST03)/WEEKSALES03 C |
| IF WEEKSALES01 < 2000000 C |
| DO SET = PROBLEM01='SALES BELOW TARGET' C |
PLEASE FILL IN RULE DEFINITION. 15.44.57
It sets variable WEEKSALES01 equal to the sum of the variables WEEKSALES01 and DB_INVAMT01@G%%CTR1.
When the rule started, variable WEEKSALES01 was initialized to 0.
The expression DB_INVAMT01@G%%CTR1 is defined as follows:
When the rule started, %%CTR1 was set to 0.
Each day, as INVAMT01 is updated from the daily invoice total for Division 1, as set forth in the explanation of rule ARWARN04 in the section describing Problem 4, a new generation of INVAMT01 is created. The most recent generation of INVAMT01 is always generation 0. The next most recent generations are generations 1, 2, and so on.
The rule first adds the value of generation 0 of each of the database variables into WEEKSALES01, WEEKSALES02, and so on.
The rule then adds 1 to the counter, CTR1, which represents the generation number.
If CTR1 is less than 5, it returns to LABEL: ACCUM to calculate another day’s worth of values. If CTR1 is greater than or equal to 5, meaning that all the figures for the week have been accumulated, the rule proceeds to accumulate margins based on these figures.
After calculating margins, the rule begins the analysis on all the figures.
Examining the Balancing Checks of the ON Block EXECUTE ACCUMSLS
Figure 89 Balancing Checks of the ON Block EXECUTE ACCUMSLS
LIBRARY : CTB.PROD.RULES RULE : ARWARN05
COMMAND ===> SCROLL===> CRSR
+---------------------------------- BROWSE -----------------------------------+
| IF WEEKSALES01 < 2000000 C |
| DO SET = PROBLEM01='SALES BELOW TARGET' C |
| DO SET = CTR1=999 C |
| ELSE |
| DO SET = PROBLEM01=BLANK C |
| IF WEEKSALES02 < 3000000 C |
| DO SET = PROBLEM02='SALES BELOW TARGET' C |
| DO SET = CTR1=999 C |
| ELSE |
| DO SET = PROBLEM02=BLANK C |
| IF WEEKSALES03 < 600000 C |
| DO SET = PROBLEM03='SALES BELOW TARGET' C |
| DO SET = CTR1=999 C |
| ELSE |
| DO SET = PROBLEM03=BLANK C |
| IF MARGIN1 < 0.15 C |
| DO SET = PROBLEM04='MARGIN BELOW TARGET' C |
| DO SET = CTR1=999 C |
| ELSE |
| DO SET = PROBLEM04=BLANK C |
PLEASE FILL IN RULE DEFINITION. 15.46.10
This group of IF statements performs the balancing checks for the accumulated amounts, in the following basic pattern:
999 in all these IF statements indicates that one or more of the rules has been broken. Later, this will be used to terminate the rule NOTOK.
Figure 90 Last Balancing Checks of the ON Block EXECUTE ACCUMSL
LIBRARY : CTB.PROD.RULES RULE : ARWARN05
COMMAND ===> SCROLL===> CRSR
+---------------------------------- BROWSE -----------------------------------+
| DO SET = PROBLEM03=BLANK C |
| IF MARGIN1 < 0.15 C |
| DO SET = PROBLEM04='MARGIN BELOW TARGET' C |
| DO SET = CTR1=999 C |
| ELSE |
| DO SET = PROBLEM04=BLANK C |
| IF MARGIN2 < 0.2 C |
| DO SET = PROBLEM05='MARGIN BELOW TARGET' C |
| DO SET = CTR1=999 C |
| ELSE |
| DO SET = PROBLEM05=BLANK C |
| IF MARGIN3 < 0.38 C |
| DO SET = PROBLEM06='MARGIN BELOW TARGET' C |
| DO SET = CTR1=999 C |
| ELSE |
| DO SET = PROBLEM06=BLANK C |
| ALWAYS |
| DO PRINT = INTRAC WEEKLY INVOICE ANALYSIS F C |
| DO PRINT = FOR %%SYSDATE F C |
| DO PRINT = %%BLANK F C |
PLEASE FILL IN RULE DEFINITION. 15.47.07
Figure 91 End of Rule ARWARN05
LIBRARY : CTB.PROD.RULES RULE : ARWARN05
COMMAND ===> SCROLL===> CRSR
+---------------------------------- BROWSE -----------------------------------+
| ELSE |
| DO SET = PROBLEM06=BLANK C |
| ALWAYS |
| DO PRINT = INTRAC WEEKLY INVOICE ANALYSIS F C |
| DO PRINT = FOR %%SYSDATE F C |
| DO PRINT = %%BLANK F C |
| DO PRINT = SALES OF DIV 1 - %%WEEKSALES01 %%PROBLEM01 F C |
| DO PRINT = SALES OF DIV 2 - %%WEEKSALES02 %%PROBLEM02 F C |
| DO PRINT = SALES OF DIV 3 - %%WEEKSALES03 %%PROBLEM03 F C |
| DO PRINT = %%BLANK F C |
| DO PRINT = MARGIN OF DIV 1 - %%MARGIN1 %%PROBLEM04 F C |
| DO PRINT = MARGIN OF DIV 2 - %%MARGIN2 %%PROBLEM05 F C |
| DO PRINT = MARGIN OF DIV 3 - %%MARGIN3 %%PROBLEM06 F C |
| IF CTR1=999 C |
| DO TERMINAT = NOTOK COD 0099 |
| ELSE |
| DO TERMINAT = OK COD 0000 |
| =========================================================================== |
| EXECUTE UPON C |
| ON |
PLEASE FILL IN RULE DEFINITION. 15.47.56
After the rule performs all checks, it prints the balancing report. Note how any problems that are encountered are referred to by using the variable names PROBLEM01, PROBLEM02, and so on, in each print line.
The rule terminates either OK or NOTOK, depending on the value of CTR1. As defined earlier, if any errors are encountered, variable CTR1 is set to 999.
Parent Topic |