Producing Printed Reports
10.9 Report Writer Examples
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).
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.
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.
(continued on next page)
Producing Printed Reports 10–49