The Report Writer
| RD and REPORT | |
| Report groups | |
| GENERATE |
RD and REPORT
The Report Writer builds paginated output from declarations. RD defines the report in DATA DIVISION, and the file is declared like any other file with REPORT IS:
FILE SECTION.
FD REPORT-FILE REPORT IS PAYROLL-REPORT.
RD PAYROLL-REPORT
CONTROL IS FINAL WS-DEPT.
Report groups
Report groups describe the lines: PAGE HEADING at the top of each page, DETAIL for every row, and CONTROL FOOTING when a control field changes. LINE, COLUMN, and SUM do the layout and the math:
01 DETAIL-LINE TYPE DE.
02 LINE +1 COLUMN 1 PIC X(10) SOURCE WS-DEPT.
02 COLUMN 12 PIC $$$,$$9.99 SUM WS-PAY.
GENERATE
In PROCEDURE DIVISION, GENERATE emits a group. GENERATE DETAIL-LINE prints one row, and the Report Writer automatically inserts headings, page breaks, and control footings as it goes.
Next: Sorting with the SORT verb
Article author: Arthur Isaev