Compaq COBOL AAQ2G1FTK User Manual

Page 333

Advertising
background image

Producing Printed Reports

10.8 Programming a Report Writer Report

When the value of a control name changes, a control break occurs. The Report
Writer acknowledges this break only when you execute a GENERATE or
TERMINATE statement for the report, which causes the information related
to that CONTROL report group to be printed.

In the following example, the report defines two control totals (MONTH-CONTRL
and WEEK-CONTRL) in the CONTROL clause. The source of these control totals
is in an input file named IN-FILE. The file must be already sorted in ascending
sequence by MONTH-CONTRL and WEEK-CONTRL. The Report Writer facility
automatically monitors these fields in the input file for any changes. If a new
record contains different data than the previous record read, Report Writer
triggers a control break.

FD

IN-FILE.

01

INPUT-RECORD.
02

MONTH-CONTRL

PIC...

02

...

02

...

02

WEEK-CONTRL

PIC...

FD

REPORT-FILE

REPORT IS SALES-REPORT.

.
.
.

REPORT SECTION.
RD

SALES-REPORT.
CONTROLS ARE MONTH-CONTRL, WEEK-CONTRL.

01

DETAIL-LINE TYPE IS DETAIL.

01

TYPE IS CONTROL FOOTING MONTH-CONTRL.

01

TYPE IS CONTROL FOOTING WEEK-CONTRL.

In the previous example, if the value in WEEK-CONTRL changes, a break occurs
and Report Writer processes the CONTROL FOOTING WEEK-CONTRL report
group. If the value in MONTH-CONTRL changes, a break occurs and Report
Writer processes both CONTROL FOOTING report groups, because a break in
any control field implies a break in all lower-order control fields as well.

The same process occurs if you include similar CONTROL HEADING report
groups. However, CONTROL HEADING control breaks occur from a break to
minor levels, while CONTROL FOOTING control breaks occur from a break to
major levels.

The following example demonstrates the use of FINAL, a special control field that
names the most major control field. You specify FINAL once, in the CONTROL
clause, as the most major control level. When you code FINAL, a FINAL control
break and subsequent FINAL headings and footings occur during program
execution: once at the beginning of the report (as part of the report group,
CONTROL HEADING FINAL), before the first detail line is printed; and once at
the end of the report (as part of the report group, CONTROL FOOTING FINAL),
after the last detail line is printed.

01

TYPE CONTROL FOOTING FINAL.
02

LINE 58.
04

COLUMN 1 PIC X(32) VALUE

"TOTAL SALES FOR YEAR-TO-DATE WAS".

04

COLUMN 45 PIC 9(6).99 SOURCE TOTAL-SALES.

Producing Printed Reports 10–33

Advertising