Compaq COBOL AAQ2G1FTK User Manual

Page 336

Advertising
background image

Producing Printed Reports
10.8 Programming a Report Writer Report

10.8.11.4 RESET Option

When a CONTROL FOOTING group is printed, the SUM counter in that group
is automatically reset to zero. If you want to specify when a SUM counter is
reset to zero, use the RESET phrase. RESET names a data item in a higher-
level CONTROL FOOTING that will cause the SUM counter to be reset to zero.
RESET is used only with a SUM clause.

The following example sums SALES, resetting the counter to zero only when it
encounters a new year (YEAR). This prevents the sum from being reset to zero
when a new month causes a control break, giving a running total of the months
within the year.

RD

SALES-REPORT.
.
.
.
CONTROLS ARE YEAR, EACH-MONTH, EACH-WEEK.

.
.
.

01

TYPE CONTROL FOOTING EACH-MONTH
02

COLUMN 10

PIC ZZ9.99

SUM SALES RESET ON YEAR.

10.8.11.5 UPON Option

Another SUM option is the UPON phrase. This phrase allows selective
subtotaling for the DETAIL Report Group named in the phrase. When you
use the UPON phrase, you cannot reference the sum counter in the SUM clause.
You can use any File or Working-Storage Section elementary numeric data item.

When you code the UPON option with the SUM clause, the value of the data
items of the SUM clause will be added whenever the TYPE DETAIL report group
you name in the UPON option is generated.

WORKING-STORAGE SECTION.

.
.
.

01

WORK-AREA.
.
.
.
03

ADD-COUNTER

PIC 9

VALUE 1.

REPORT SECTION.

.
.
.

01

FIRST-DETAIL-LINE TYPE IS DETAIL LINE IS PLUS 2.
.
.
.

01

TYPE IS CONTROL FOOTING FINAL.

05

LINE IS PLUS 3.

.
.
.
05

LINE PLUS 2.
10

COLUMN 5

PIC Z(3)9

SUM ADD-COUNTER
UPON FIRST-DETAIL-LINE.

10–36 Producing Printed Reports

Advertising