Producing Printed Reports
10.8 Programming a Report Writer Report
This example produces the following output:
1
2
3
4
5
column 1234567890123456789012345678901234567890123456789012345
TOTAL SALES FOR YEAR-TO-DATE WAS
953208.90
10.8.11 Defining and Incrementing Totals
In addition to using either the VALUE or SOURCE clause to assign a value to a
report item, you can use the SUM clause to accumulate values of report items.
This clause establishes a sum counter that is automatically summed during the
processing of the report. You code a SUM clause only in a TYPE CONTROL
FOOTING report group.
The identifiers of the SUM clause are either elementary numeric data items not
in the Report Section or other sum counters in the Report Section that are at
the same or lower level in the control hierarchy of the report, as specified in the
CONTROL clause.
The SUM clause provides three forms of sum accumulation: subtotaling,
crossfooting, and rolling-forward. These forms are detailed in this section.
See Section 10.3 for further discussion.
10.8.11.1 Subtotaling
In subtotaling, the SUM clause references elementary numeric data items that
appear in the File or Working-Storage Sections and then generates sums of those
items.
In the following example, EACH-WEEK represents a CONTROL clause name.
COST represents a numeric data item in the File Section that indicates weekly
expenses for a company. DAY and MONTH indicate the particular day and
month.
01
TYPE CONTROL FOOTING EACH-WEEK.
02
LINE PLUS 2.
03
COLUMN 1
PIC IS X(30)
VALUE IS
"TOTAL EXPENSES FOR WEEK/ENDING".
03
COLUMN 33
PIC IS X(4)
SOURCE IS MONTH.
03
COLUMN 39
PIC IS X(2)
SOURCE IS DAY.
03
WEEK-AMT
COLUMN 45
PIC ZZ9.99 SUM COST.
This example produces the following subtotal output:
1
2
3
4
5
column 12345678901234567890123456789012345678901234567890
TOTAL EXPENSES FOR WEEK/ENDING
JULY
02
799.23
When the value of EACH-WEEK changes, a control break occurs that causes this
TYPE CONTROL FOOTING report group to print. The value of the sum counter
is edited according to the PIC clause accompanying the SUM clause. Then the
sum lines are printed in the location specified by the items’ LINE and COLUMN
clauses.
10–34 Producing Printed Reports
Содержание COBOL AAQ2G1FTK
Страница 22: ......
Страница 30: ......
Страница 94: ......
Страница 110: ......
Страница 146: ......
Страница 180: ......
Страница 194: ...Processing Files and Records 6 1 Defi...
Страница 300: ......
Страница 490: ......
Страница 516: ......
Страница 517: ......
Страница 530: ......
Страница 534: ......
Страница 590: ......
Страница 620: ......