The specific commands used for printing or writing data
are given in the Commands and logic
sections.
A D V E R T I S E M E N T
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.
000110 ENVIRONMENT DIVISION.
000120 INPUT-OUTPUT SECTION.
000130 FILE-CONTROL.
000140
:
000210 SELECT PRINT-FILE ASSIGN TO PRINTER.
000220
000230
000240 DATA DIVISION.
000250 FILE SECTION.
:
000580 FD PRINT-FILE.
000590 01 REPORT-OUT PIC X(80).
:
000630 WORKING-STORAGE SECTION.
000640
:
001040 01 PRINT-HEADERS.
001050 03 P-TITLE.
001060 05 P-TITLE-TXT PIC X(49) VALUE
001070 ' Batch Control Program - Error Report. Page:'.
001080 05 P-PAGE-NO PIC Z9 VALUE ZERO.
001090 03 COL-HEAD-1 PIC X(31)
001100 VALUE ' PART CUST/ DATE QUANT'.
001110 03 COL-HEAD-2 PIC X(24)
001120 VALUE ' NO SUP NO SUP/REC'.
001130
001140 01 PRINT-LINE.
001150 03 P-PART-NO PIC X(8).
001160 03 PIC X VALUE SPACE.
001170 03 P-CUS-SUP-NO PIC X(6).
001180 03 PIC XX VALUE SPACES.
001190 03 P-DATE-S-D.
001200 05 P-DATE-1 PIC XX.
001210 05 PIC X VALUE '/'.
001220 05 P-DATE-2 PIC XX.
001230 05 PIC X VALUE '/'.
001240 05 P-DATE-3 PIC XX.
001250 03 PIC X VALUE SPACE.
001260 03 P-QUANT PIC Z(4)9.
001270
001280 01 P-FOOTER.
001290 03 TOT-REC-TXT PIC X(21)
001300 VALUE 'Total record number: '.
001310 03 P-REC-COUNT PIC ZZ9 VALUE ZERO.
001320
001330 01 P-BATCH-REC.
001340 03 BAT-TITLE PIC X(38)
001350 VALUE ' HASH TOTALS IN BATCH CONTROL RECORD'.
001360 03 BATCH-SOURCE PIC X(29) VALUE SPACES .
001370 03 P-BAT-CUS-SUPP.
001380 05 BAT-CUS-SUP PIC X(25)
001390 VALUE ' CUSTOMER/SUPPLIER NOS: '.
001400 05 BAT-C-S-N-TOT PIC Z(7)9.
001410 03 P-BAT-DATE.
001420 05 BAT-DATE PIC X(9)
001430 VALUE ' DATES: '.
001440 05 BAT-D-S-D-TOT PIC Z(7)9.
001450 03 P-BAT-QUANT.
001460 05 BAT-QUANT PIC X(14)
001470 VALUE ' QUANTITIES: '.
001480 05 BAT-Q-TOT PIC Z(7)9.
001490 03 P-BAT-PART.
001500 05 BAT-PART PIC X(12)
001510 VALUE ' PART NOS: '.
001520 05 BAT-P-N-TOT PIC Z(7)9.
: