REFERENCE

Establish summing capability for a non-printing detail item and sum the item in a control footing.
Restriction: This topic applies only when the AppMaster Builder AddPack has been installed, and applies only to Windows platforms.

Syntax:

R[EFERENCE] [IS] dataname PIC[TURE] [IS] picclause
    [DATA-NAME [IS] fieldname]

Parameters:

dataname Data item being referenced
DATA-NAME fieldname Name a sum accumulator established by a SUM or REFERENCE clause. Do not define fieldname in Working-Storage. At generation, AMB inserts fieldname after the level number in the report group. DATA-NAME moves the value of the internal SUM accumulator to fieldname.
  Code DATA-NAME when a SUM UPON clause references a DETAIL report group, when the program references a sum accumulator, or when a sum accumulator requires a data name for qualification.
PIC picclause Specify the format of dataname. If dataname is a report mock-up field instead of a Working-Storage field, the next matching COBOL picture in the report mock-up is the picclause for dataname.

Comments:

  • When you code a REFERENCE statement, the PIC clause must match the PIC clause in the record description. For example:
    01    COST-DETAIL TYPE DETAIL
           MOCKUP LINE 9
           SOURCE WS-DEPT
           SOURCE WS-EMPLOYEE
           SOURCE WS-CITY
           REFERENCE EMP-CTR   PIC 999
     01    TYPE CONTROL FOOTING
           MOCKUP LINE 9
           SOURCE WS-DEPT
           SUM EMP-CTR
     WS01  EMP-CTR     PIC 999   VALUE 1.
  • If one of the PIC clauses were PIC 9(3), Report Writer would not find a match.
  • In a REFERENCE statement, the data item referenced must be defined in Working-Storage with a VALUE clause. The value in the VALUE clause tells Report Writer the increment to add to the internal accumulator each time the detail line prints. In the previous example, AMB adds 1 to the internal accumulator whenever the detail line prints.
  • The generated program does not describe the referenced field, dataname, on the report mock-up detail line, nor display it on the printed detail line.

Example:

                  LAST COUNT    QUANTITY       QUANTITY     QUANTITY
LOCATION          DATE          IN STOCK       ISSUED       RECEIVED
XXXXXXXXXXXX    99/99/99         ZZZ,ZZ9       ZZZ,ZZ9       ZZZ,ZZ9
                                 -------       -------      --------
TOTAL BY LOCATION:             Z,ZZZ,ZZ9     Z,ZZZ,ZZ9     Z,ZZZ,ZZ9

TOTAL NUMBER OF SALES BY LOCATION: ZZZ,ZZ9
 01    DETAIL-LINE TYPE IS DETAIL.
       MOCKUP LINE 16
       SOURCE WS-LOCATION-CODE     GROUP INDICATE
       SOURCE WS-LAST-COUNT-MONTH    PIC 99
       SOURCE WS-LAST-COUNT-DAY      PIC 99
       SOURCE WS-LAST-COUNT-YEAR     PIC 99
       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 17 THRU 20
       SUM WS-NO-OF-SALES            PIC ZZZ9