CIS133C CLASS 14
FILE SECTION.
FD REPORT1-FILE
RECORD CONTAINS 133 CHARACTERS
LABEL RECORDS ARE STANDARD.
01 REPORT1-RECORD.
05 CC PIC X.
05 RPT1-PRINT-LINE PIC X(132).
WORKING-STORAGE.
01 WS-COUNTERS.
05 WS-CNT-PAGE PIC 9(3) VALUE ZERO.
05 WS-CNT-LINES PIC 9(3) VALUE 99.
01 WS-WORK-AREA.
05 WS-RUN-DATE.
10 WS-RUN-YY PIC 99 VALUE ZERO.
10 WS-RUN-MM PIC 99 VALUE ZERO.
10 WS-RUN-DD PIC 99 VALUE ZERO.
05 WS-MAX-LINES PIC 99 VALUE 50.
05 WS-LINE-SPACING PIC 9 VALUE 1.
01 RPT1-HDR1.
05 FILLER PIC X(6) VALUE 'DATE: '.
05 RPT1-MM PIC 99 VALUE ZERO.
05 FILLER PIC X VALUE '/'.
05 RPT1-DD PIC 99 VALUE ZERO.
05 FILLER PIC X VALUE '/'.
05 FILLER PIC X(110) VALUE SPACES.
05 FILLER PIC X(5) VALUE 'PAGE '.
05 RPT1-PAGE-NBR PIC ZZ9 VALUE ZERO.
01 RPT1-HDR2 PIC X(132) VALUE
'REPORT HEADER TWO LINE'.
01 RPT1-COLHDR1 PIC X(132) VALUE
'COLUMN HEADER ONE LINE'.
PROCEDURE DIVISION.
B000-INITIALIZE.
Open files.
ACCEPT WS-RUN-DATE FROM DATE.
MOVE WS-RUN-MM TO RPT1-MM.
MOVE WS-RUN-DD TO RPT1-DD.
MOVE WS-RUN-YY TO RPT1-YY.
Do whatever else is necessary in the init paragraph.
PERFORM X000-READ-INPUT1.
C000-PROCESSING.
IF WS-CNT-LINES > WS-MAX-LINES
PERFORM C100-RPT1-NEW-PAGE
END-IF.
IF VALID-RECORD
PERFORM C200-RPT1-DETAIL-LINE
END-IF.
PERFORM X000-READ-INPUT1.
C100-RPT1-NEW-PAGE.
ADD 1 TO WS-CNT-PAGE.
MOVE WS-CNT-PAGE TO RPT1-PAGE-NBR.
MOVE RPT1-HDR1 TO RPT1-PRINT-LINE.
PERFORM W100-PRINT-RPT1.
MOVE RPT1-HDR2 TO RPT1-PRINT-LINE.
MOVE 1 TO WS-LINE-SPACING.
PERFORM W100-PRINT-RPT1.
MOVE RPT1-COLHDR1 TO RPT1-PRINT-LINE.
MOVE 3 TO WS-LINE-SPACING.
PERFORM W100-PRINT-RPT1.
C200-RPT1-DETAIL-LINE.
Move in-fields to out-fields (format line).
Calculate intermediate-fields.
Move calculated intermediate-fields to out-fields.
MOVE RPT1-DETAIL-LINE TO RPT1-PRINT-LINE.
MOVE 2 TO WS-LINE-SPACING.
PERFORM W100-PRINT-RPT1.
W100-PRINT-RPT1.
IF WS-CNT-LINES > WS-MAX-LINES
WRITE REPORT1-RECORD AFTER ADVANCING PAGE
MOVE 1 TO WS-CNT-LINES
ELSE
WRITE REPORT1-RECORD
AFTER ADVANCING WS-LINE-SPACING
ADD WS-LINE-SPACING TO WS-CNT-LINES
END-IF.
NOTES on the above code . . .
- The carriage control byte is defined in the FD and each WORKING-STORAGE line is moved to the remaining 132 bytes of the FD before the write is performed.
- WS-CNT-LINES is intialized to 99 to handle the first page condition.
- WS-LINE-SPACING works for carriage control (AFTER ADVANCING) as well line counting.
|