A
person preparing a report manually would probably obtain the summary data by
first typing all the detail lines and then going back and adding up all of the
typed figures to get the necessary column totals. This would be impractical for
the computer to do. Instead, a program must accumulate its summary totals from
each detail record as that record is processed. After the last record is
processed, the summary total calculations will be complete. Then final output
of the summary line requires only that the summary totals be edited, and
printed. All of this can be accomplished by defining a data field in the WORKING-STORAGE
SECTION for each summary total required and adding the values for each
detail record to these data fields as they are calculated. Data fields used in
this way are called accumulators because they are used to
accumulate totals.
To
use a data field as an accumulator, you must:
01 ACCUMULATORS.
02 TOTAL-BALANCE PIC 9(7)V99 VALUE
ZEROS.
or
MOVE TOTAL-BALANCE TO
SUMRY-LINE-BALANCE
WRITE PRINT-LINE FROM SUMRY-LINE
AFTER
ADVANCING 2 LINES