|
5.1 Printing and Writing Data
The specific commands used for printing or writing data are given in the Commands and logic
sections. Much of how that data will look, such as in a report, is defined in the data division.
The following code is taken from a full program given in the Sample code section should
illustrate how a printed report is defined in the data division. If writing to a file it would be virtually identical
(see Sample code section for an example of this).
If you wished to print a report in the form of a table then you would first have to assign an identifier name to the
printer in the environment division using the select clause.
003220 MOVE PAGE-NO TO P-PAGE-NO
003230 WRITE REPORT-OUT FROM P-TITLE AFTER PAGE
Here the page number is moved to the P-TITLE sub-group member (of PRINT-HEADERS)
P-PAGE-NO. The following line effectively means: MOVE P-TITLE TO REPORT-OUT WRITE REPORT-OUT AFTER PAGE
(AFTER PAGE instructs the printer to start a new page)
It is in the data groups involved in printing (or writing to a file) that data editing (such as zero-supression)
is performed
By simply changing the ASSIGN PRINT-FILE TO 'PRINTER' to ASSIGN PRINT-FILE TO 'report.txt' would be all that
was required to produce the same report in a file called 'report.txt' and add ORGANIZATION IS LINE SEQUENTIAL. Although, the AFTER PAGE
and AFTER ... LINES would have no effect
|