To sum data items in a report

Restriction: This topic applies only when the AppMaster Builder AddPack has been installed, and applies only to Windows platforms.
  1. In the Program Painter, identify the SOURCE or REFERENCE statements in the CONTROL FOOTING report groups that you want to sum.
  2. Use the following syntax as your guide:
       SUM     dataname [dataname] ...
               [UPON detlineidentifier [detlineidentifier] ...]
               [RESET [FINAL] controlname]
               [DATA-NAME fieldname]
               [PICTURE picclause]
  3. Use the following guidelines as you code:
    • Sum the data items within the report group from left to right, top to bottom, as they will appear on the printed report.
    • If the report has more than one detail line, use the UPON parameter to name the line where the summing takes place.
    • To override the AMB default of resetting SUM accumulators to zero after each control break, use the RESET parameter to do a running total and specify which control break should reset the accumulator.
    • To automatically move the value in the Report Writer field accumulator to a field you can reference in the Procedure Division, for example, to test the field or do further calculations, create the field by naming it in the DATA-NAME fieldname parameter.
    • Include a picture clause for SUM statements if multiple fields are strung together on the mock-up. A PIC clause indicates the next matching COBOL picture in the mock-up is the COBOL picture for this data item.

For example:

   MOCK    STOCKRPT
   01      TYPE IS REPORT HEADING    
               NEXT GROUP IS NEXT PAGE
           MOCKUP LINES 1 THRU 5
           SOURCE WS-DATE

   01      TYPE IS PAGE HEADING
               NEXT GROUP PLUS 3
           MOCKUP LINES 6 THRU 8
           SOURCE WS-DATE

   01      TYPE IS CONTROL HEADING WS-LOCATION-CODE
           MOCKUP LINES 10 THRU 12

   01      PART-DETAIL TYPE IS DETAIL 
               NEXT GROUP PLUS 1
           MOCKUP LINE 13
           SOURCE WS-LOCATION-CODE    GROUP INDICATE
           SOURCE WS-LAST-COUNT-MONTH
           SOURCE WS-LAST-COUNT-DAY  
           SOURCE WS-LAST-COUNT-YEAR 
           SOURCE WS-QTY-IN-STOCK
           SOURCE WS-QTY-ISSUED
           SOURCE WS-QTY-RECEIVED
           REFERENCE WS-NO-OF-SALES   PIC 9999

   01      TYPE IS CONTROL FOOTING WS-LOCATION-CODE
           MOCKUP LINES 14 THRU 18
           MOCKUP LINES 19 THRU 22
           SUM WS-QTY-IN-STOCK
           SUM WS-QTY-ISSUED
           SUM WS-QTY-RECEIVED
           SUM WS-NO-OF-SALES

   01      TYPE IS CONTROL FOOTING FINAL
           MOCKUP LINES 19 THRU 22
           SUM WS-QTY-IN-STOCK
           SUM WS-QTY-ISSUED
           SUM WS-QTY-RECEIVED
           SUM WS-NO-OF-SALES

   01      TYPE IS PAGE FOOTING
               LINE PLUS 2
           MOCKUP LINE 24
           SOURCE IS PAGE-COUNTER

   01      TYPE IS REPORT FOOTING
               LINE PLUS 3
           MOCKUP LINE 26
Note:
  • Use SUM for CONTROL FOOTING report groups only.
  • AMB creates an internal SUM accumulator field for each data item specified. The name of this field is dataname-nnnn, where nnnn is a 4-digit number. Each time the detail line containing the data item prints, AMB adds its value to the accumulator. AMB clears the accumulators either after each control break (the default) or after a control break you specify with the RESET option.