Compaq COBOL
User Manual


Previous Contents Index

10.9.3 EX1007---Detail Report Program

Example 10-7 (EX1007) is a Report Writer program that uses the REPORT HEADING, PAGE HEADING, DETAIL, CONTROL FOOTING, and REPORT FOOTING report groups and produces a detail report---EX1007.LIS (shown in Figure 10-16). The output includes both subtotals and rolling-forward totals.

Example 10-7 Sample Program EX1007

IDENTIFICATION DIVISION. 
PROGRAM-ID. EX1007. 
ENVIRONMENT DIVISION. 
CONFIGURATION SECTION. 
INPUT-OUTPUT SECTION. 
FILE-CONTROL. 
        SELECT CUSTOMER-FILE ASSIGN TO "MASTER.DAT". 
        SELECT SORT-FILE     ASSIGN TO "EX1007-SORTIN.TMP". 
        SELECT SORTED-FILE   ASSIGN TO "EX1007-SORTOUT.TMP". 
        SELECT PRINTER-FILE  ASSIGN TO "EX1007.LIS". 
DATA DIVISION. 
FILE SECTION. 
 
SD      SORT-FILE. 
01      SORTED-CUSTOMER-MASTER-FILE. 
        02  SORT-NAME                   PIC X(26). 
        02                              PIC X(73). 
 
FD      CUSTOMER-FILE. 
01      CUSTOMER-MASTER-FILE            PIC X(99). 
 
FD      SORTED-FILE. 
01      CUSTOMER-MASTER-FILE. 
        02  NAME. 
                03  LAST-NAME           PIC X(15). 
                03  FIRST-NAME          PIC X(10). 
                03  MIDDLE-INIT         PIC X. 
        02  ADDRESS                     PIC X(20). 
        02  CITY                        PIC X(20). 
        02  STATE                       PIC XX. 
        02  ZIP                         PIC 99999. 
        02  SALESMAN-NUMBER             PIC 99999. 
        02  INVOICE-DATA. 
               03  INVOICE-NUMBER       PIC 999999. 
               03  INVOICE-SALES        PIC S9(5)V99. 
               03  INVOICE-DATE. 
                      04  INV-DAY       PIC 99. 
                      04  INV-MO        PIC 99. 
                      04  INV-YR        PIC 9999. 
FD      PRINTER-FILE 
        REPORT IS MASTER-LIST. 
WORKING-STORAGE SECTION. 
01      UNEDITED-DATE. 
        02  UE-YEAR     PIC 9999. 
        02  UE-MONTH    PIC 99. 
        02  UE-DAY      PIC 99. 
        02  FILLER      PIC X(6). 
 
01      ONE-COUNT       PIC 9 VALUE 1. 
REPORT SECTION. 
 
RD      MASTER-LIST 
        PAGE LIMIT IS 66 
        HEADING       1 
        FIRST DETAIL  13 
        LAST DETAIL   55 
        CONTROLS ARE FINAL 
                      NAME. 
01      REPORT-HEADER TYPE IS REPORT HEADING NEXT GROUP NEXT PAGE. 
        02      LINE 24. 
                03      COLUMN 45 
                        PIC X(31) VALUE ALL "*". 
        02      LINE 25. 
                03      COLUMN 45 
                        PIC X VALUE "*". 
                03      COLUMN 75 
                        PIC X VALUE "*". 
        02      LINE 26. 
                03      COLUMN 45 
                        PIC X(31) VALUE "*    Customer Master File     *". 
        02      LINE 27. 
                03      COLUMN 45 
                        PIC X VALUE "*". 
                03      COLUMN 75 
                        PIC X VALUE "*". 
        02      LINE 28. 
                03      COLUMN 45 
                        PIC X VALUE "*". 
                03      COLUMN 55 
                        PIC Z9 
                        SOURCE UE-DAY. 
                03      COLUMN 57 
                        PIC X   VALUE "-". 
                03      COLUMN 58 
                        PIC 99 
                        SOURCE UE-MONTH. 
                03      COLUMN 60 
                        PIC X   VALUE "-". 
                03      COLUMN 61 
                        PIC 9999 
                        SOURCE UE-YEAR. 
                03      COLUMN 75 
                        PIC X   VALUE "*". 
        02      LINE 29. 
                03      COLUMN  45 
                        PIC X VALUE "*". 
                03      COLUMN 75 
                        PIC X VALUE "*". 
        02      LINE 30. 
                03      COLUMN  45 
                        PIC X(31) VALUE "*       Report EX1007         *". 
        02      LINE 31. 
                03      COLUMN  45 
                        PIC X(31) VALUE "*       Detail Report         *". 
        02      LINE 32. 
                03      COLUMN  45 
                        PIC X VALUE "*". 
                03      COLUMN 75 
                        PIC X VALUE "*". 
        02      LINE 33. 
                03      COLUMN  45 
                        PIC X VALUE "*". 
                03      COLUMN 75 
                        PIC X VALUE "*". 
        02      LINE 34. 
                03      COLUMN  45 
                        PIC X VALUE "*". 
                03      COLUMN 75 
                        PIC X VALUE "*". 
        02      LINE 35. 
                03      COLUMN  45 
                        PIC X(31) VALUE ALL "*". 
01      TYPE IS PAGE HEADING. 
        02      LINE  5. 
                03      COLUMN 1 
                        PIC X(27) VALUE "CUSTOMER MASTER FILE REPORT". 
                03      COLUMN 105 
                        PIC X(4)  VALUE "PAGE". 
                03      COLUMN 109 
                        PIC ZZZ9 
                        SOURCE PAGE-COUNTER. 
        02      LINE  7. 
                03      COLUMN  1 
                        PIC X VALUE "+". 
                03      COLUMN 2 
                        PIC X(110) VALUE ALL "-". 
                03      COLUMN 112 
                        PIC X VALUE "+". 
        02      LINE  8. 
                03      COLUMN  1 
                        PIC X VALUE "|". 
                03      COLUMN 10 
                        PIC X(4) VALUE "NAME". 
                03      COLUMN  29 
                        PIC X VALUE "|". 
                03      COLUMN 43 
                        PIC X(7) VALUE "ADDRESS". 
                03      COLUMN  81 
                        PIC X VALUE "|". 
                03      COLUMN  91 
                        PIC X(7) VALUE "INVOICE". 
                03      COLUMN 112 
                        PIC X VALUE "|". 
        02      LINE  9. 
                03      COLUMN  1 
                        PIC X VALUE "|". 
                03      COLUMN 2 
                        PIC X(110) VALUE ALL "-". 
                03      COLUMN 112 
                        PIC X VALUE "|". 
        02      LINE  10. 
                03      COLUMN  1 
                        PIC X(6) VALUE "| LAST". 
                03      COLUMN 16 
                        PIC X(7) VALUE "| FIRST". 
                03      COLUMN 26 
                        PIC X(4) VALUE "|MI|". 
                03      COLUMN  35 
                        PIC X(6) VALUE "STREET". 
                03      COLUMN 48 
                        PIC X VALUE "|". 
                03      COLUMN 52 
                        PIC X(4) VALUE "CITY". 
                03      COLUMN  71 
                        PIC X VALUE "|". 
                03      COLUMN 72 
                        PIC X(2) VALUE "ST". 
                03      COLUMN 74 
                        PIC X VALUE "|". 
                03      COLUMN 76 
                        PIC X(3) VALUE "ZIP". 
                03      COLUMN 81 
                        PIC X VALUE "|". 
                03      COLUMN 83 
                        PIC X(4) VALUE "DATE". 
                03      COLUMN 90 
                        PIC X VALUE "|". 
                03      COLUMN  92 
                        PIC X(6) VALUE "NUMBER". 
                03      COLUMN 98 
                        PIC X VALUE "|". 
                03      COLUMN 103 
                        PIC X(6) VALUE "AMOUNT". 
                03      COLUMN 112 
                        PIC X VALUE "|". 
                02      LINE  11. 
                        03      COLUMN 1 
                                PIC X VALUE "+". 
                        03      COLUMN 2 
                                PIC X(110) VALUE ALL "-". 
                        03      COLUMN 112 
                                PIC X VALUE "+". 
01      DETAIL-LINE 
        TYPE DETAIL 
        LINE PLUS 2. 
        02 COLUMN 1     PIC X(15) SOURCE LAST-NAME. 
        02 COLUMN 17    PIC X(10) SOURCE FIRST-NAME. 
        02 COLUMN 28    PIC XX    SOURCE MIDDLE-INIT. 
        02 COLUMN 30    PIC X(20) SOURCE ADDRESS. 
        02 COLUMN 51    PIC X(20) SOURCE CITY. 
        02 COLUMN 72    PIC XX    SOURCE STATE. 
        02 COLUMN 75    PIC 99999 SOURCE ZIP. 
        02 COLUMN 81    PIC Z9    SOURCE INV-DAY. 
        02 COLUMN 83    PIC X     VALUE "-". 
        02 COLUMN 84    PIC 99    SOURCE INV-MO. 
        02 COLUMN 86    PIC X     VALUE "-". 
        02 COLUMN 87    PIC 9999  SOURCE INV-YR. 
        02 COLUMN 92    PIC 9(6)  SOURCE INVOICE-NUMBER. 
        02 COLUMN 99    PIC $$$,$$$,$$$.99- 
                                  SOURCE INVOICE-SALES. 
        02 DETAIL-COUNT PIC S9(10) SOURCE ONE-COUNT. 
        02 INV-AMOUNT   PIC S9(9)V99 SOURCE INVOICE-SALES. 
01      TYPE IS CONTROL FOOTING NAME 
                NEXT GROUP IS PLUS 2. 
        02      LINE IS PLUS 2. 
                03      COLUMN  72 
                        PIC X(41) VALUE ALL "*". 
        02      LINE IS PLUS 1. 
                03      COLUMN  20  PIC X(17) VALUE " TOTAL RECORDS: ". 
                03 IDC  COLUMN  40  PIC ZZZ,ZZZ,ZZ9 SUM ONE-COUNT. 
                03 IIA  COLUMN  99  PIC $$$,$$$,$$$.99- SUM INVOICE-SALES. 
        02      LINE IS PLUS 1. 
                03      COLUMN  72 
                        PIC X(41) VALUE ALL "*". 
01      FINAL-FOOTING TYPE IS CONTROL FOOTING FINAL 
                      NEXT GROUP NEXT PAGE. 
        02      LINE IS PLUS 2. 
                03      COLUMN  72 
                        PIC X(41) VALUE ALL "*". 
        02      LINE IS PLUS 1. 
                03      COLUMN  14 PIC X(21) VALUE "GRAND TOTAL RECORDS: ". 
                03 FDC  COLUMN  40 PIC ZZZ,ZZZ,ZZ9 SUM IDC. 
                03      COLUMN  72 PIC X(22) VALUE " GRAND TOTAL INVOICES:". 
                03 FIA  COLUMN  95 PIC $,$$$,$$$,$$$.99- SUM IIA. 
        02      LINE IS PLUS 1. 
                03      COLUMN  72 
                        PIC X(41) VALUE ALL "*". 
01      REPORT-FOOTER TYPE IS REPORT FOOTING. 
        02      LINE 24  ON NEXT PAGE COLUMN  45 
                         PIC X(31) VALUE ALL "*". 
        02      LINE 25. 
                03      COLUMN  45 
                        PIC X VALUE "*". 
                03      COLUMN 75 
                        PIC X VALUE "*". 
        02      LINE 26. 
                03      COLUMN  45 
                        PIC X(31) VALUE "*    Customer Master File     *". 
        02      LINE 27. 
                03      COLUMN  45 
                        PIC X VALUE "*". 
                03      COLUMN 75 
                        PIC X VALUE "*". 
        02      LINE 28. 
                03      COLUMN  45 
                        PIC X VALUE "*". 
                03      COLUMN  55 
                        PIC Z9 
                        SOURCE UE-DAY. 
                03      COLUMN  57 
                        PIC X   VALUE "-". 
                03      COLUMN  58 
                        PIC 99 
                        SOURCE UE-MONTH. 
                03      COLUMN  60 
                        PIC X   VALUE "-". 
                03      COLUMN  61 
                        PIC 9999 
                        SOURCE UE-YEAR. 
                03      COLUMN  75 
                        PIC X VALUE "*". 
        02      LINE 29. 
                03      COLUMN  45 
                        PIC X VALUE "*". 
                03      COLUMN 75 
                        PIC X VALUE "*". 
        02      LINE 30. 
                03      COLUMN  45 
                        PIC X(31) VALUE "*       End of EX1007.LIS     *". 
        02      LINE 31. 
                03      COLUMN  45 
                        PIC X VALUE "*". 
                03      COLUMN 75 
                        PIC X VALUE "*". 
        02      LINE 32 COLUMN  45 
                            PIC X(31) VALUE ALL "*". 
PROCEDURE DIVISION. 
DECLARATIVES. 
BOR SECTION. 
        USE BEFORE REPORTING REPORT-HEADER. 
EOR SECTION. 
        USE BEFORE REPORTING REPORT-FOOTER. 
EOR-A. 
        DISPLAY "*** Created EX1007.LIS ***". 
END DECLARATIVES. 
MAIN SECTION. 
000-DO-SORT. 
        SORT SORT-FILE ON ASCENDING KEY SORT-NAME 
             WITH DUPLICATES IN ORDER 
             USING CUSTOMER-FILE 
             GIVING SORTED-FILE. 
000-START. 
        DISPLAY "*** EX1007 ***". 
        DISPLAY "Enter Current Date (YYYYMMDD) :". 
        ACCEPT UNEDITED-DATE. 
        OPEN INPUT  SORTED-FILE. 
        OPEN OUTPUT PRINTER-FILE. 
        INITIATE MASTER-LIST. 
        PERFORM 200-READ-MASTER UNTIL NAME = HIGH-VALUES. 
100-END-OF-FILE. 
        TERMINATE MASTER-LIST. 
        CLOSE SORTED-FILE, PRINTER-FILE. 
        STOP RUN. 
200-READ-MASTER. 
        READ SORTED-FILE AT END MOVE HIGH-VALUES TO NAME. 
        IF NAME NOT = HIGH-VALUES GENERATE DETAIL-LINE. 

Figure 10-16 EX1007.LIS Listing



10.9.4 EX1008---Detail Report Program

Example 10-8 (EX1008) is a Report Writer program that uses the REPORT HEADING, PAGE HEADING, DETAIL, CONTROL FOOTING, and REPORT FOOTING report groups and produces a detail report---EX1008.LIS (shown in Figure 10-17).

Example 10-8 Sample Program EX1008

IDENTIFICATION DIVISION. 
PROGRAM-ID. EX1008. 
ENVIRONMENT DIVISION. 
CONFIGURATION SECTION. 
INPUT-OUTPUT SECTION. 
FILE-CONTROL. 
        SELECT CUSTOMER-FILE ASSIGN TO "MASTER.DAT". 
        SELECT SORT-FILE     ASSIGN TO "EX1008-SORTIN.TMP". 
        SELECT SORTED-FILE   ASSIGN TO "EX1008-SORTOUT.TMP". 
        SELECT PRINTER-FILE  ASSIGN TO "EX1008.LIS". 
 
DATA DIVISION. 
FILE SECTION. 
SD      SORT-FILE. 
01      SORTED-CUSTOMER-MASTER-FILE. 
        02  SORT-NAME                   PIC X(26). 
        02                              PIC X(73). 
 
FD      CUSTOMER-FILE. 
01      CUSTOMER-MASTER-FILE            PIC X(99). 
 
FD      SORTED-FILE. 
01      SORTED-RECORD. 
        02  SORTED-NAME                 PIC X(26). 
        02  S-ADDRESS                   PIC X(20). 
        02  S-CITY                      PIC X(20). 
        02  S-STATE                     PIC XX. 
        02  S-ZIP                       PIC 99999. 
        02  S-SALESMAN-NUMBER           PIC 99999. 
        02  S-INVOICE-DATA. 
                03  S-INVOICE-NUMBER    PIC 999999. 
                03  S-INVOICE-SALES     PIC S9(5)V99. 
                03  S-INVOICE-DATE. 
                        04  S-INV-DAY   PIC 99. 
                        04  S-INV-MO    PIC 99. 
                        04  S-INV-YR    PIC 9999. 
FD      PRINTER-FILE 
        REPORT IS MASTER-LIST. 
WORKING-STORAGE SECTION. 
 
01      UNEDITED-DATE. 
        02  UE-YEAR     PIC 9999. 
        02  UE-MONTH    PIC 99. 
        02  UE-DAY      PIC 99. 
        02  FILLER      PIC X(6). 
01      ONE-COUNT                       PIC 9 VALUE 1. 
01      EOF                             PIC X VALUE "N". 
01      SAVE-INVOICE-SALES              PIC S9(9)V99 VALUE 0. 
01      CUSTOMER-MASTER-RECORD. 
        02  NAME. 
                03  LAST-NAME           PIC X(15). 
                03  FIRST-NAME          PIC X(10). 
                03  MIDDLE-INIT         PIC X. 
        02  ADDRESS                     PIC X(20). 
        02  CITY                        PIC X(20). 
        02  STATE                       PIC XX. 
        02  ZIP                         PIC 99999. 
        02  SALESMAN-NUMBER             PIC 99999. 
        02  INVOICE-DATA. 
                03  INVOICE-NUMBER      PIC 999999. 
                03  INVOICE-SALES       PIC S9(5)V99. 
                03  INVOICE-DATE. 
                        04  INV-DAY     PIC 99. 
                        04  INV-MO      PIC 99. 
                        04  INV-YR      PIC 9999. 
REPORT SECTION. 
 
RD      MASTER-LIST 
        PAGE LIMIT IS 66 
        HEADING       1 
        FIRST DETAIL  13 
        LAST DETAIL   55 
        CONTROLS ARE FINAL. 
01      REPORT-HEADER TYPE IS REPORT HEADING NEXT GROUP NEXT PAGE. 
        02      LINE 24. 
                03      COLUMN 45 
                        PIC X(31) VALUE ALL "*". 
        02      LINE 25. 
                03      COLUMN 45 
                        PIC X VALUE "*". 
                03      COLUMN 75 
                        PIC X VALUE "*". 
        02      LINE 26. 
                03      COLUMN 45 
                        PIC X(31) VALUE "*    Customer Master File     *". 
 
        02      LINE 27. 
                03      COLUMN 45 
                        PIC X VALUE "*". 
                03      COLUMN 75 
                        PIC X VALUE "*". 
        02      LINE 28. 
                03      COLUMN 45 
                        PIC X VALUE "*". 
                03      COLUMN 55 
                        PIC Z9 
                        SOURCE UE-DAY. 
                03      COLUMN 57 
                        PIC X   VALUE "-". 
                03      COLUMN 58 
                        PIC 99 
                        SOURCE UE-MONTH. 
                03      COLUMN 60 
                        PIC X   VALUE "-". 
                03      COLUMN 61 
                        PIC 9999 
                        SOURCE UE-YEAR. 
                03      COLUMN 75 
                        PIC X VALUE "*". 
        02      LINE 29. 
                03      COLUMN  45 
                        PIC X VALUE "*". 
                03      COLUMN 75 
                        PIC X VALUE "*". 
        02      LINE 30. 
                03      COLUMN  45 
                        PIC X(31) VALUE "*       Report EX1008         *". 
        02      LINE 31. 
                03      COLUMN  45 
                        PIC X(31) VALUE "*       Detail Report         *". 
        02      LINE 32. 
                03      COLUMN  45 
                        PIC X VALUE "*". 
                03      COLUMN 75 
                        PIC X VALUE "*". 
        02      LINE 33. 
                03      COLUMN  45 
                        PIC X VALUE "*". 
                03      COLUMN 75 
                        PIC X VALUE "*". 
        02      LINE 34. 
                03      COLUMN  45 
                        PIC X(31) VALUE ALL "*". 
01        TYPE IS PAGE HEADING. 
        02      LINE  5. 
                03      COLUMN 1 
                        PIC X(27) VALUE "CUSTOMER MASTER FILE REPORT". 
                03      COLUMN 105 
                        PIC X(4)  VALUE "PAGE". 
                03      COLUMN 109 
                        PIC ZZZ9 
                        SOURCE PAGE-COUNTER. 
        02      LINE  7. 
                03      COLUMN  1 
                        PIC X VALUE "+". 
                03      COLUMN 2 
                        PIC X(110) VALUE ALL "-". 
                03      COLUMN 112 
                        PIC X VALUE "+". 
        02      LINE  8. 
                03      COLUMN  1 
                        PIC X VALUE "|". 
                03      COLUMN 10 
                        PIC X(4) VALUE "NAME". 
                03      COLUMN  29 
                        PIC X VALUE "|". 
                03      COLUMN 43 
                        PIC X(7) VALUE "ADDRESS". 
                03      COLUMN  81 
                        PIC X VALUE "|". 
                03      COLUMN  91 
                        PIC X(7) VALUE "INVOICE". 
                03      COLUMN 112 
                        PIC X VALUE "|". 
        02      LINE  9. 
                03      COLUMN  1 
                        PIC X VALUE "|". 
                03      COLUMN 2 
                        PIC X(110) VALUE ALL "-". 
                03      COLUMN 112 
                        PIC X VALUE "|". 
        02      LINE  10. 
                03      COLUMN  1 
                        PIC X(6) VALUE "| LAST". 
                03      COLUMN 16 
                        PIC X(7) VALUE "| FIRST". 
                03      COLUMN 26 
                        PIC X(4) VALUE "|MI|". 
                03      COLUMN  35 
                        PIC X(6) VALUE "STREET". 
                03      COLUMN 48 
                        PIC X VALUE "|". 
                03      COLUMN 52 
                        PIC X(4) VALUE "CITY". 
                03      COLUMN  71 
                        PIC X VALUE "|". 
                03      COLUMN 72 
                        PIC X(2) VALUE "ST". 
                03      COLUMN 74 
                        PIC X VALUE "|". 
                03      COLUMN 76 
                        PIC X(3) VALUE "ZIP". 
                03      COLUMN 81 
                        PIC X VALUE "|". 
                03      COLUMN 83 
                        PIC X(4) VALUE "DATE". 
                03      COLUMN 90 
                        PIC X VALUE "|". 
                03      COLUMN  92 
                        PIC X(6) VALUE "NUMBER". 
                03      COLUMN 98 
                        PIC X VALUE "|". 
                03      COLUMN 103 
                        PIC X(6) VALUE "AMOUNT". 
                03      COLUMN 112 
                        PIC X VALUE "|". 
        02      LINE  11. 
                03      COLUMN 1 
                        PIC X VALUE "+". 
                03      COLUMN 2 
                        PIC X(110) VALUE ALL "-". 
                03      COLUMN 112 
                        PIC X VALUE "+". 
01      DETAIL-LINE 
        TYPE DETAIL LINE IS PLUS 1. 
        02 COLUMN 1     PIC X(15) SOURCE LAST-NAME. 
        02 COLUMN 17    PIC X(10) SOURCE FIRST-NAME. 
        02 COLUMN 28    PIC XX    SOURCE MIDDLE-INIT. 
        02 COLUMN 30    PIC X(20) SOURCE ADDRESS. 
        02 COLUMN 51    PIC X(20) SOURCE CITY. 
        02 COLUMN 72    PIC XX    SOURCE STATE. 
        02 COLUMN 75    PIC 99999 SOURCE ZIP. 
        02 COLUMN 81    PIC Z9    SOURCE INV-DAY. 
        02 COLUMN 83    PIC X     VALUE "-". 
        02 COLUMN 84    PIC 99    SOURCE INV-MO. 
        02 COLUMN 86    PIC X     VALUE "-". 
        02 COLUMN 87    PIC 9999    SOURCE INV-YR. 
        02 COLUMN 92    PIC 9(6)  SOURCE INVOICE-NUMBER. 
        02 COLUMN 99    PIC $$$,$$$,$$$.99- 
                                      SOURCE SAVE-INVOICE-SALES. 
01      FINAL-FOOTING TYPE IS CONTROL FOOTING FINAL 
                      NEXT GROUP NEXT PAGE. 
        02      LINE IS PLUS 2. 
                03      COLUMN  70 
                        PIC X(43) VALUE ALL "*". 
        02      LINE IS PLUS 1. 
                03      COLUMN  70 PIC X(24) VALUE "*  GRAND TOTAL INVOICES:". 
                03 FIA  COLUMN  94 PIC $,$$$,$$$,$$$.99- SUM INVOICE-SALES. 
                03      COLUMN  111 PIC XXX VALUE " * ". 
        02      LINE IS PLUS 1. 
                03      COLUMN  70 
                        PIC X(43) VALUE ALL "*". 
01      REPORT-FOOTER TYPE IS REPORT FOOTING. 
        02      LINE 24  ON NEXT PAGE COLUMN  45 
                        PIC X(31) VALUE ALL "*". 
        02      LINE 25. 
                03      COLUMN  45 
                        PIC X VALUE "*". 
                03      COLUMN 75 
                        PIC X VALUE "*". 
        02      LINE 26. 
                03      COLUMN  45 
                        PIC X(31) VALUE "*    Customer Master File     *". 
        02      LINE 27. 
                03      COLUMN  45 
                        PIC X VALUE "*". 
                03      COLUMN 75 
                        PIC X VALUE "*". 
        02      LINE 28 . 
                03      COLUMN  45 
                        PIC X VALUE "*". 
                03      COLUMN  55 
                        PIC Z9 
                        SOURCE UE-DAY. 
                03      COLUMN  57 
                        PIC X    VALUE "-". 
                03      COLUMN  58 
                        PIC 99 
                        SOURCE UE-MONTH. 
                03      COLUMN  60 
                        PIC X    VALUE "-". 
                03      COLUMN  61 
                        PIC 9999 
                        SOURCE UE-YEAR. 
                03      COLUMN  75 
                        PIC X VALUE "*". 
        02      LINE 29. 
                03      COLUMN  45 
                        PIC X VALUE "*". 
                03      COLUMN 75 
                        PIC X VALUE "*". 
        02      LINE 30 COLUMN  45 
                        PIC X(31) VALUE "*     End of Report EX1008    *". 
        02      LINE 31. 
                03      COLUMN  45 
                        PIC X VALUE "*". 
                03      COLUMN 75 
                        PIC X VALUE "*". 
        02      LINE 32 COLUMN  45 
                        PIC X(31) VALUE ALL "*". 
PROCEDURE DIVISION. 
 
DECLARATIVES. 
BOR SECTION. 
        USE BEFORE REPORTING REPORT-HEADER. 
EOR SECTION. 
        USE BEFORE REPORTING REPORT-FOOTER. 
EOR-A. 
        DISPLAY "*** Created EX1008.LIS ***". 
DET SECTION. 
        USE BEFORE REPORTING DETAIL-LINE. 
DET-A. 
        IF SORTED-NAME = NAME 
                MOVE SORTED-RECORD TO CUSTOMER-MASTER-RECORD 
                ADD INVOICE-SALES TO SAVE-INVOICE-SALES 
                SUPPRESS PRINTING. 
        IF NAME = SPACES SUPPRESS PRINTING. 
END DECLARATIVES. 
MAIN SECTION. 
000-DO-SORT. 
        SORT SORT-FILE ON ASCENDING KEY SORT-NAME 
             WITH DUPLICATES IN ORDER 
             USING CUSTOMER-FILE 
             GIVING SORTED-FILE. 
 
000-START. 
        DISPLAY "*** EX1008 ***". 
        DISPLAY "Enter Current Date (YYYYMMDD) :". 
        ACCEPT UNEDITED-DATE. 
        OPEN INPUT  SORTED-FILE. 
        OPEN OUTPUT PRINTER-FILE. 
        MOVE SPACES TO NAME. 
        INITIATE MASTER-LIST. 
        PERFORM 200-READ-MASTER UNTIL EOF = "Y". 
100-END-OF-FILE. 
        TERMINATE MASTER-LIST. 
        CLOSE SORTED-FILE, PRINTER-FILE. 
        STOP RUN. 
200-READ-MASTER. 
        READ SORTED-FILE AT END MOVE "Y" TO EOF 
                                MOVE HIGH-VALUES TO SORTED-NAME. 
        GENERATE DETAIL-LINE. 
        IF SORTED-NAME NOT = NAME 
            MOVE S-INVOICE-SALES TO SAVE-INVOICE-SALES. 
 
        IF EOF NOT = "Y" 
            MOVE SORTED-RECORD TO CUSTOMER-MASTER-RECORD. 

Figure 10-17 EX1008.LIS Listing



Previous Next Contents Index