Producing Printed Reports
10.5 Programming a Conventional File Report
Example 10–2 Checking for the Page-Overflow Condition
.
.
.
PROCEDURE DIVISION.
A000-BEGIN.
.
.
.
A100-FIRST-REPORT-ROUTINES.
*
* A901-HEADER-ROUTINE executes whenever the number of lines written exceeds
* the number of lines on the 66-line default logical page.
*
WRITE A-LINE1 AFTER ADVANCING 2 LINES.
ADD 2 TO REPORT1-LINE-COUNT.
IF REPORT1-LINE-COUNT > 65 PERFORM A901-HEADER-ROUTINE.
.
.
.
A500-SECOND-REPORT-ROUTINES.
*
* This routine uses only the first 50 lines of the 66-line report.
*
WRITE A-LINE2 AFTER ADVANCING 2 LINES.
ADD 2 TO REPORT2-LINE-COUNT.
IF REPORT2-LINE-COUNT IS GREATER THAN 50
PERFORM A902-HEADER-ROUTINE.
.
.
.
A901-HEADER-ROUTINE.
WRITE A-LINE1 FROM REPORT1-HEADER-LINE-1 AFTER ADVANCING PAGE.
MOVE 0 TO REPORT1-LINE-COUNT.
ADD 1 TO REPORT1-LINE-COUNT.
.
.
.
A902-HEADER-ROUTINE.
WRITE A-LINE2 FROM REPORT2-HEADER-LINE-1 AFTER ADVANCING PAGE.
MOVE 0 TO REPORT2-LINE-COUNT.
ADD 1 TO REPORT2-LINE-COUNT.
.
.
.
Although the WRITE statement allows you to check for a page-overflow condition,
you can also use a line counter that tracks the number of lines that appear on a
page. Section 10.5.3.2 describes this in more detail.
10.5.3.2 Using a Line Counter
A line counter is another method of tracking the number of lines that appear on a
page. If you define a line counter in the Working-Storage Section of your program,
each time a line is written or skipped the line counter value is incremented by
one.
Your program should contain a routine that checks the line counter value before
it writes or skips the next line. If the value is less than the limit you have set, it
writes or skips. If the value equals or exceeds the limit you have set, the program
executes header routines that allow it to advance to the next logical page.
10–8 Producing Printed Reports
Содержание COBOL AAQ2G1FTK
Страница 22: ......
Страница 30: ......
Страница 94: ......
Страница 110: ......
Страница 146: ......
Страница 180: ......
Страница 194: ...Processing Files and Records 6 1 Defi...
Страница 300: ......
Страница 490: ......
Страница 516: ......
Страница 517: ......
Страница 530: ......
Страница 534: ......
Страница 590: ......
Страница 620: ......