Previous Topic

Next Topic

Book Contents

Book Index

Solution - Details

In this Control-M/Analyzer solution, the rule

In this rule, you will learn several new features, including

Opening Rule ARWARN04

  1. Select rule ARWARN04 for browsing.

    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.

    Figure 74 Rule ARWARN04

            LIBRARY : CTB.PROD.RULES                                RULE : ARWARN04

    COMMAND ===>                                                    SCROLL===> CRSR

    +---------------------------------- BROWSE -----------------------------------+

    | OWNER   M66                      GROUP INTRAC                               |

    | UPDATED 20/12/99  -  15:02:19    BY M66                                     |

    | DESC    ANALYZE AND REPORT ON DIV ARDATA FILES                              |

    | OPTIONS                                                                     |

    | =========================================================================== |

    | EXECUTE INIT     UPON                                                   C   |

    | ON DATA                                                                     |

    | ALWAYS                                                                      |

    |   DO PRINT    =         INTRAC DAILY DIVISIONAL INVOICE ANALYSIS    F   C   |

    |   DO PRINT    =                     FOR  %%SYSDATE                  F   C   |

    |   DO PRINT    = -- ------- -------- ------- ------- --------- ----- F   C Y |

    |             ----                                                            |

    |   DO PRINT    = DV CUST    CUST #   INV #   DATE    AMOUNT    PROBL F   C Y |

    |             EM                                                              |

    |   DO PRINT    = -- ------- -------- ------- ------- --------- ----- F   C Y |

    |             ----                                                            |

    |   DO SET      = ERRORS=0                                                C   |

    |   DO SET      = TOLERABLES=0                                            C   |

    |   DO SET      = BLANK=' '                                               C   |

    | =========================================================================== |

    PLEASE FILL IN RULE DEFINITION.                                        15.22.36

    The rule consists of the following five ON blocks:

  2. Place the cursor on the line beginning with the string "EXECUTE INIT," and press PF08/PF20, or enter the DOWN command.

    Figure 75 EXECUTE INIT Block

            LIBRARY : CTB.PROD.RULES                                RULE : ARWARN04

    COMMAND ===>                                                    SCROLL===> CRSR

    +---------------------------------- BROWSE -----------------------------------+

    | EXECUTE INIT     UPON                                                   C   |

    | ON DATA                                                                     |

    | ALWAYS                                                                      |

    |   DO PRINT    =         INTRAC DAILY DIVISIONAL INVOICE ANALYSIS    F   C   |

    |   DO PRINT    =                     FOR  %%SYSDATE                  F   C   |

    |   DO PRINT    = -- ------- -------- ------- ------- --------- ----- F   C Y |

    |             ----                                                            |

    |   DO PRINT    = DV CUST    CUST #   INV #   DATE    AMOUNT    PROBL F   C Y |

    |             EM                                                              |

    |   DO PRINT    = -- ------- -------- ------- ------- --------- ----- F   C Y |

    |             ----                                                            |

    |   DO SET      = ERRORS=0                                                C   |

    |   DO SET      = TOLERABLES=0                                            C   |

    |   DO SET      = BLANK=' '                                               C   |

    | =========================================================================== |

    | EXECUTE INPUT    UPON                                                   C   |

    | ON FILE       FILENAME IOAP.V610.SAMPREPS(CTBREP1)                          |

    |    MODE DS    LINECT 0000    DATASTAMP                                      |

    | WHEN LINE 001     - 999     COL 003     - 015              STOP    AND/OR   |

    |      STRING = .NE.TOTALINVOICES                                             |

    PLEASE FILL IN RULE DEFINITION.                                        15.24.47

    The DO PRINT instructions print the report heading lines.

    As in previous rules you examined, this rule defines a variable that accumulates the error count, in this case, ERRORS. Another variable, TOLERABLES, that stores the accumulated number of tolerable errors, is defined. Tolerable errors will result in warning messages appearing on the report, but will still result in an OK condition and with the database being updated.

  3. Place the cursor on the line beginning with the string "EXECUTE INPUT," and press PF08/PF20, or enter the DOWN command.

    Figure 76 EXECUTE INPUT Block

            LIBRARY : CTB.PROD.RULES                                RULE : ARWARN04

    COMMAND ===>                                                    SCROLL===> CRSR

    +---------------------------------- BROWSE -----------------------------------+

    | EXECUTE INPUT    UPON                                                   C   |

    | ON FILE       FILENAME IOAP.V610.SAMPREPS(CTBREP1)                          |

    |    MODE DS    LINECT 0000    DATASTAMP                                      |

    | WHEN LINE 001     - 999     COL 003     - 015              STOP    AND/OR   |

    |      STRING = .NE.TOTALINVOICES                                             |

    |   DO EXTRACT  = DIV                                                         |

    |                 LEVEL 0 LINE +000 COL 0001 - 0002 PROCESS          TYP      |

    |   DO EXTRACT  = CUST                                                        |

    |                 LEVEL 0 LINE +000 COL 0003 - 0030 PROCESS          TYP      |

    |   DO EXTRACT  = CUSTNO                                                      |

    |                 LEVEL 0 LINE +000 COL 0031 - 0038 PROCESS          TYP      |

    |   DO EXTRACT  = INVNO                                                       |

    |                 LEVEL 0 LINE +000 COL 0039 - 0045 PROCESS          TYP      |

    |   DO EXTRACT  = DATE                                                        |

    |                 LEVEL 0 LINE +000 COL 0046 - 0051 PROCESS          TYP      |

    |   DO EXTRACT  = AMT                                                         |

    |                 LEVEL 0 LINE +000 COL 0052 - 0061 PROCESS          TYP      |

    |   DO EXTRACT  = AMT%%DIV                                                    |

    |                 LEVEL 0 LINE +000 COL 0052 - 0061 PROCESS          TYP SU   |

    |   DO EXTRACT  = COST                                                        |

    PLEASE FILL IN RULE DEFINITION.                                        15.25.36

    The value in the INPUT ON block for a file has the identical structure to the INPUT ON block for a report. As a reminder, the structure is:

    ON Parameter

    The ON parameter specifies the data source as a file and provides the file name. The rule can process a file in one of the following two MODEs:

    This rule processes the invoice file in DS mode.

    WHEN Criteria

    In this file, two WHEN criteria describe the two types of rows on which the rule needs to take action:

    DO Parameters

    The DO EXTRACT parameters extract information from each Detail Row of the file when the search criteria specified in the WHEN parameter are satisfied. Shown below is a sample of the data in an extracted row (Figure 77), corresponding to each of the DO EXTRACT parameters that are specified in the rule:

    Figure 77 Sample Data for DO EXTRACT Definition

    Div                           Customer---------------- Invoice -----------------

    # Customer Name                 #       #   -Date-  Amount    Cost       Misc.

    01ABC COMPANY                 1ABC0001CJ39394020892   2040.00   1800.00   157.95

    01SHANGHAI MOTORS             1SHA0002CJ39395030892    245.00     30.00    10.00

    01TELEPATHIC ENTERPRISES      1TEL0001CJ39396040892  10987.55  10005.00   300.00

    01CBG COMPANY                 1CBG0001CJ39397020892  12044.00  12000.00     0.00

    01TERRIBLE TRUCKERS           1TER0001CJ39398030892 345245.00 308000.00  4750.00

    01BIG DEAL COMPUTING LTD      1BIG0001CJ39399040892    987.25    600.00     0.00

    01UNDERGROUND TELEPHONES INC  1UND0001CJ39400020892     40.00     20.00     0.00

    01MITSUISUN ELECTRONICS       1MIT0001CJ39401030892   6776.45   6000.00   115.00

    01TOTALINVOICES                                     378365.25 338455.00  6789.00

    02SWAHILI ARMED FORCES        2SWA0001MJ24545040892  10987.55  10005.00   275.00

    02GOVERNMENT OF BOSSNIA       2GBO0001MJ24546020892  27500.00  26800.00   200.50

    02METZUYAN MANUFACTURING      2MET0001MJ24547030892  13465.00  12830.00   347.00

    02TELEPATHIC ENTERPRISES      2TEL0002MJ24548040892   5590.00   5600.00     0.00

    02BANGUP AIRCRAFT             2BAN0001MJ24549020892   2150.00   1800.00     7.00

    02ZAPIT HYDRO & ELECTRIC      2ZAP0001MJ24550030892  45222.00  40900.00   815.00

    02POST OF THE AMERICAS        2POS0001MJ24551040892  10000.50   8005.00   500.00

    02GROSS AIRLINES              2GRO0001MJ24552020892    197.75    100.00     0.00

    ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8

    Note the following details in the second to last DO parameter in Figure 76 (DO EXTRACT = AMT%%DIV):

  4. Now examine the remainder of this INPUT block. Use PF08/PF20, or enter the DOWN command, and scroll forward to the DO SET parameter set to NAME=SUBSTR(1,7CUST), immediately following the DO EXTRACT parameters.
  5. Place the cursor on the line beginning with DO SET = NAME, and press Enter.

    Figure 78 DO SET Parameters

            LIBRARY : CTB.PROD.RULES                                RULE : ARWARN04

    COMMAND ===>                                                    SCROLL===> CRSR

    +---------------------------------- BROWSE -----------------------------------+

    |   DO SET      = NAME=SUBSTR(1,7,CUST)                                   C   |

    |   DO SET      = MONTHYR=SUBSTR(3,4,DATE)                                C   |

    |   DO BLOCK    = CHKDETL  ARG                                            C   |

    | WHEN LINE 001     - 999     COL 003     - 015              STOP    AND/OR   |

    |      STRING = TOTALINVOICES                                                 |

    |   DO EXTRACT  = DIV                                                         |

    |                 LEVEL 0 LINE +000 COL 0001 - 0002 PROCESS          TYP      |

    |   DO EXTRACT  = TAMT%%DIV                                                   |

    |                 LEVEL 0 LINE +000 COL 0052 - 0061 PROCESS          TYP      |

    |   DO EXTRACT  = TCOST%%DIV                                                  |

    |                 LEVEL 0 LINE +000 COL 0062 - 0071 PROCESS          TYP      |

    | =========================================================================== |

    | EXECUTE ENDJOB   UPON                                                   C   |

    | ON DATA                                                                     |

    | ALWAYS                                                                      |

    |   DO SET      = I=1                                                     C   |

    | LABEL: TOTALS                                                               |

    | IF       I GT 3                                                         C   |

    |   DO GOTO     LABEL FINISH                                                  |

    | ELSE                                                                        |

    PLEASE FILL IN RULE DEFINITION.                                        15.28.55

    These last parameters of the rule are defined as follows:

    When the rule finds the desired rows, it extracts three variables using DO EXTRACT actions: DIV, TAMT%%DIV, and TCOST%%DIV.

    When Control-M/Analyzer reads the string %%DIV, it substitutes the value of the variable DIV in place of the string %%DIV. For example, if the rule were looking at the TOTALINVOICES row for division 01, see Figure 77"Sample Data for DO EXTRACT Definition", the variable DIV would be set to 01. The names of the next two variables extracted would be set to TAMT01 and TCOST01, substituting 01 for %%DIV in the variable names TAMT%%DIV and TCOST%%DIV.

    Similarly, if the rule were looking at the TOTALINVOICES row for division 02, it would extract variables whose names would be DIV, equal to a value of 02, TAMT02, and TCOST02.

    While the variable has been specified only once, no matter how many divisions there are in the file, the result will be unique variable names for the invoice amount and cost for each division.

    This capability to have the system dynamically generate variable names is a powerful feature of Control-M/Analyzer rule definition parameters, which is used several times within this sample rule.

Examining the CHKDETL Block

You will now examine the CHKDETL block to see what balancing actions are performed on each detail row of the file.

  1. Using PF08/PF20, or execute the DOWN command, scroll forward until you see the ON block EXECUTE CHKDETL.
  2. Place the cursor on the line beginning with the string "EXECUTE CHKDETL," and press PF08/PF20, or execute the DOWN command.

    Figure 79 ON Block EXECUTE CHKDETL

            LIBRARY : CTB.PROD.RULES                                RULE : ARWARN04

    COMMAND ===>                                                    SCROLL===> CRSR

    +---------------------------------- BROWSE -----------------------------------+

    | EXECUTE CHKDETL  UPON                                                   C   |

    | ON DATA                                                                     |

    | IF       DIV NE 01 AND DIV NE 02 AND DIV NE 03                          C   |

    |   DO SET      = PROBLEM='DIV'                                           C   |

    |   DO SET      = ERRORS=ERRORS+1                                         C   |

    |   DO BLOCK    = PRINT    ARG PROBLEM                                    C   |

    | IF       DIV = 01 AND AMT > 400000                                      C   |

    |   DO SET      = PROBLEM='AMT'                                           C   |

    |   DO SET      = ERRORS=ERRORS+1                                         C   |

    |   DO BLOCK    = PRINT    ARG PROBLEM                                    C   |

    | IF       DIV = 01 AND AMT > 200000 AND AMT <= 400000                    C   |

    |   DO SET      = PROBLEM='AMT-WRN'                                       C   |

    |   DO SET      = TOLERABLES=TOLERABLES+1                                 C   |

    |   DO BLOCK    = PRINT    ARG PROBLEM                                    C   |

    | IF       DIV = 02 OR DIV = 03 AND AMT > 200000                          C   |

    |   DO SET      = PROBLEM='AMT'                                           C   |

    |   DO SET      = ERRORS=ERRORS+1                                         C   |

    |   DO BLOCK    = PRINT    ARG PROBLEM                                    C   |

    | IF       DIV = 02 OR DIV = 03 AND AMT > 100000 AND AMT <= 200000        C   |

    |   DO SET      = PROBLEM='AMT-WRN'                                       C   |

    PLEASE FILL IN RULE DEFINITION.                                        15.31.20

    The parameters of the rule are defined as follows:

  1. Examine the rest of this ON block. Use PF08/PF20, or execute the DOWN command, and scroll forward to the bottom of the rule.

    Figure 80 End of Rule ARWARN04

            LIBRARY : CTB.PROD.RULES                                RULE : ARWARN04

    COMMAND ===>                                                    SCROLL===> CRSR

    +---------------------------------- BROWSE -----------------------------------+

    | IF       DIV = 02 OR DIV = 03 AND AMT > 100000 AND AMT <= 200000        C   |

    |   DO SET      = PROBLEM='AMT-WRN'                                       C   |

    |   DO SET      = TOLERABLES=TOLERABLES+1                                 C   |

    |   DO BLOCK    = PRINT    ARG PROBLEM                                    C   |

    | IF       MONTHYR NE DB_PROCESS_MONTH                                    C   |

    |   DO SET      = PROBLEM='DATE'                                          C   |

    |   DO SET      = ERRORS=ERRORS+1                                         C   |

    |   DO BLOCK    = PRINT    ARG PROBLEM                                    C   |

    | =========================================================================== |

    | EXECUTE PRINT    UPON                                                   C   |

    | ON DATA                                                                     |

    | ALWAYS                                                                      |

    |   DO PRINT    = %%DIV %%NAME %%CUSTNO %%INVNO %%DATE %%AMT %%PROBLE F   C Y |

    |             M                                                               |

    | =========================================================================== |

    | EXECUTE          UPON                                                   C   |

    | ON                                                                          |

    ======= >>>>>>>>>>>>>>> END OF RULE DEFINITION PARAMETERS <<<<<<<<<<<<<<< =====

                                                                                  

                                                                                  

    PLEASE FILL IN RULE DEFINITION.                                        15.33.09

    The EXECUTE PRINT block has just one parameter, a DO PRINT instruction. Rather than having a separate ON block such as this one for printing, the rule also could have been defined with multiple instances of these same print instructions in the CHKDETL block. This illustrates how rules can often be written differently and still accomplish the same balancing task.

Ending the rule

You will now examine the ON block, ENDJOB, which is executed sequentially after all file input has been processed by the ON block called INPUT. It is physically located further up in this rule.

The last tasks before this rule ends are to

To accomplish this, only one generic set of balancing instructions is necessary for all divisions. This is done by generalizing the instructions in order to insert the division code into the variable names. This requires using the %% operator, as explained in DO Parameters.

The flow of logic in the ON block, ENDJOB, is illustrated in the following diagram:

Figure 81 Flow of ON Block Logic

  1. Now examine the actual rule to see how this logic is defined. Use PF07/PF19, or execute the UP command, to scroll backward until you see ON block EXECUTE ENDJOB on the screen.
  2. Place the cursor on the line beginning with the string "EXECUTE ENDJOB," and press PF08/PF20, or execute the DOWN command.

    Figure 82 ON Block EXECUTE ENDJOB

            LIBRARY : CTB.PROD.RULES                                RULE : ARWARN04

    COMMAND ===>                                                    SCROLL===> CRSR

    +---------------------------------- BROWSE -----------------------------------+

    | EXECUTE ENDJOB   UPON                                                   C   |

    | ON DATA                                                                     |

    | ALWAYS                                                                      |

    |   DO SET      = I=1                                                     C   |

    | LABEL: TOTALS                                                               |

    | IF       I GT 3                                                         C   |

    |   DO GOTO     LABEL FINISH                                                  |

    | ELSE                                                                        |

    |   DO SET      = D=0%%I                                                  C   |

    |   DO SET      = DB_INVAMT%%D=AMT%%D                                     C   |

    |   DO SET      = DB_COST%%D=COST%%D                                      C   |

    |   DO SET      = PROBLEM=' '                                             C   |

    |   DO SET      = PROB1=' '                                               C   |

    | IF       AMT%%D NE TAMT%%D                                              C   |

    |   DO SET      = PROBLEM='    TOTAMT'                                    C   |

    |   DO SET      = ERRORS=ERRORS+1                                         C   |

    | IF       COST%%D NE TCOST%%D                                            C   |

    |   DO SET      = PROB1='    TOTCOST'                                     C   |

    |   DO SET      = ERRORS=ERRORS+1                                         C   |

    | ALWAYS                                                                      |

    PLEASE FILL IN RULE DEFINITION.                                        15.37.18

    This portion of the ON block does the following:

    1. It starts creating a variable, I, which represents the division number being processed (either 1, 2, or 3).

      There are exactly 3 divisions to process. If I is larger than 3, all divisions have been processed and the rule can proceed to the section called FINISH.

    2. The ON block creates a second variable D, which represents the division code that is attached to the variable names (either 01, 02, or 03).

      When a variable name is prefixed with the string DB_, Control-M/Analyzer identifies the variable as a database variable. In this rule, variables are updated only if the rule terminates OK. The value of two database variables is set for each division:

      DB_INVAMTxx and DB_COSTxx

      where xx is the division code. However, until the block performs a "commit" operation on these variables, these values have not been changed in the database.

    3. Two variables, PROBLEM and PROB1, are set to equal a blank value. These variables are used to hold error conditions, if the totals are out of balance.
    4. The ON block then performs the balancing analysis to see if the invoice amount for the division value that is set for AMT%%D (which was accumulated in the ON block CHKDETL) is equal to the total invoice amount, TAMT%%D (which, in turn, was extracted from the TOTALS line in the file).

      If these two amounts are not equal, the value set for the variable PROBLEM is set to the error message you want on the print line, replacing its previous blank value.

  1. Press PF08/PF20, or execute the DOWN command, to scroll forward once.

    Figure 83 Analysis on Cost Amounts

            LIBRARY : CTB.PROD.RULES                                RULE : ARWARN04

    COMMAND ===>                                                    SCROLL===> CRSR

    +---------------------------------- BROWSE -----------------------------------+

    | IF       COST%%D NE TCOST%%D                                            C   |

    |   DO SET      = PROB1='    TOTCOST'                                     C   |

    |   DO SET      = ERRORS=ERRORS+1                                         C   |

    | ALWAYS                                                                      |

    |   DO PRINT    = %%BLANK                                             F   C   |

    |   DO PRINT    = DIVISION TOTAL CHECK                                F   C   |

    |   DO PRINT    = %%D SALES: CALC  %%AMT%%D                           F   C   |

    |   DO PRINT    = %%D SALES: FILE %%TAMT%%D %%PROBLEM                 F   C   |

    |   DO PRINT    = %%D  COST: CALC  %%COST%%D                          F   C   |

    |   DO PRINT    = %%D  COST: FILE %%TCOST%%D %%PROB1                  F   C   |

    |   DO PRINT    = %%BLANK                                             F   C   |

    |   DO SET      = I=INT(I+1)                                              C   |

    |   DO GOTO     LABEL TOTALS                                                  |

    | LABEL: FINISH                                                               |

    | ALWAYS                                                                      |

    |   DO PRINT    = %%BLANK                                             F   C   |

    |   DO PRINT    = ERRORS %%ERRORS  TOLERABLE ERRORS %%TOLERABLES      F   C   |

    | IF       ERRORS > 0                                                     C   |

    |   DO COMMIT   = NONE     VAR                                            C   |

    |   DO TERMINAT = NOTOK    COD 0999                                           |

    PLEASE FILL IN RULE DEFINITION.                                        15.38.37

    As you continue looking through the rule, you see the same analysis that was done for problem analysis is performed on the cost amounts.

    1. Compare the accumulated total cost for each division to the total cost amount that was extracted from the file.
    2. Print the calculated and extracted amounts with appropriate headings and associated error messages.
  2. Now that analysis of this division's totals has been completed, add 1 to the division count.

    Return to the beginning of the ON block, to the section called TOTAL, where the rule checks if analysis has been completed for all divisions.

  3. Look at the last few instructions in the rule. Place the cursor on the line beginning with the character string "LABEL: FINISH," and press PF08/PF20, or execute the DOWN command.

    Figure 84 LABEL: FINISH

            LIBRARY : CTB.PROD.RULES                                RULE : ARWARN04

    COMMAND ===>                                                    SCROLL===> CRSR

    +---------------------------------- BROWSE -----------------------------------+

    | LABEL: FINISH                                                               |

    | ALWAYS                                                                      |

    |   DO PRINT    = %%BLANK                                             F   C   |

    |   DO PRINT    = ERRORS %%ERRORS  TOLERABLE ERRORS %%TOLERABLES      F   C   |

    | IF       ERRORS > 0                                                     C   |

    |   DO COMMIT   = NONE     VAR                                            C   |

    |   DO TERMINAT = NOTOK    COD 0999                                           |

    | IF       ERRORS = 0                                                     C   |

    |   DO COMMIT   = ALL      VAR                                            C   |

    |   DO PRINT    = DIVISIONAL FILES ARE OK. DATA BASE IS UPDATED       F   C   |

    | IF       TOLERABLES > 0                                                 C   |

    |   DO TERMINAT = OK       COD 0009                                           |

    | IF       ERRORS = 0 AND TOLERABLES = 0                                  C   |

    |   DO TERMINAT = OK       COD 0000                                           |

    | =========================================================================== |

    | EXECUTE CHKDETL  UPON                                                   C   |

    | ON DATA                                                                     |

    | IF       DIV NE 01 AND DIV NE 02 AND DIV NE 03                          C   |

    |   DO SET      = PROBLEM='DIV'                                           C   |

    |   DO SET      = ERRORS=ERRORS+1                                         C   |

    PLEASE FILL IN RULE DEFINITION.                                        15.39.49

The LABEL: FINISH instructions

  1. print the final counts of errors and tolerable errors that have been accumulated throughout the execution of the rule
  2. do not commit, or update, the database variables if there were any serious errors encountered at any time during the rule execution

    In such cases the rule terminates NOTOK, with a user code of 999.

  3. commit all variables, meaning that Control-M/Analyzer updates the database at this time, if there were no serious errors

    The rule then prints a confirming message that the database has been updated. The database variables that are updated are INVAMT01, INVAMT02, INVAMT03, COST01, COST02, and COST03.

  4. terminates the rule with user code 9 if there are tolerable errors
  5. terminates the rule with a user code of 0 if there are no errors

Parent Topic

Problem 4: Balance Divisional Accounting Files