beautypg.com

Compaq COBOL AAQ2G1FTK User Manual

Page 386

background image

Producing Printed Reports
10.10 Solving Report Problems

Example 10–12 (Cont.) Printing Labels Four-Up in Sort Order

DATA DIVISION.
FILE SECTION.
FD

INPUT-FILE.

01

INPUT-RECORD.
02

INPUT-NAME

PIC X(20).

02

INPUT-ADDRESS

PIC X(15).

02

INPUT-CITY

PIC X(10).

02

INPUT-STATE

PIC XX.

02

INPUT-ZIP

PIC 99999.

FD

REPORT-FILE.

01

REPORT-RECORD

PIC X(132).

WORKING-STORAGE SECTION.
01

LABELS-TABLE.
03

FOUR-UP OCCURS 6 TIMES INDEXED BY ROW-INDEX.
04

NAME-LINE.
05

LINE-1 OCCURS 4 TIMES INDEXED BY NAME-INDEX.
07

LABEL-NAME

PIC X(20).

07

FILLER

PIC X(10).

04

ADDRESS-LINE.
05

LINE-2 OCCURS 4 TIMES INDEXED BY ADDRESS-INDEX.
07

LABEL-ADDRESS

PIC X(15).

07

FILLER

PIC X(15).

04

CSZ-LINE.
05

LINE-3 OCCURS 4 TIMES INDEXED BY CSZ-INDEX.
07

LABEL-CITY

PIC X(10).

07

FILLER

PIC XXXX.

07

LABEL-STATE

PIC XX.

07

FILLER

PIC XXXX.

07

LABEL-ZIP

PIC 99999.

07

FILLER

PIC XXXXX.

01

END-OF-FILE

PIC X.

PROCEDURE DIVISION.
A000-BEGIN.

OPEN INPUT

INPUT-FILE

OUTPUT REPORT-FILE.

MOVE SPACES TO LABELS-TABLE.
SET ROW-INDEX, NAME-INDEX, ADDRESS-INDEX, CSZ-INDEX TO 1.
PERFORM A100-READ-INPUT UNTIL END-OF-FILE = "Y".

A050-WRAP-UP.

IF LABEL-NAME(1, 1) IS NOT EQUAL TO SPACES

PERFORM A300-PRINT-PAGE-OF-LABELS VARYING ROW-INDEX

FROM 1 BY 1 UNTIL ROW-INDEX IS GREATER THAN 6.

A050-END-OF-JOB.

CLOSE INPUT-FILE

REPORT-FILE.

DISPLAY "END OF JOB".
STOP RUN.

(continued on next page)

10–86 Producing Printed Reports