COBOL Manual for TNS and TNS/R Programs

Printer and Spooler Output
HP COBOL Manual for TNS and TNS/R Programs522555-006
30-21
Formatting Pages of a Printed Report
This file description illustrates the LINAGE clause for this type of page:
FD SHOW-LINAGE
LABEL RECORDS ARE OMITTED
LINAGE IS 60 LINES
WITH FOOTING AT 55
LINES AT TOP 3
LINES AT BOTTOM 3.
One tenet of structured programming is that there be one WRITE procedure for each
output file; the program builds the line for delivery and then performs the write
procedure. This situation is a perfect basis for using the LINAGE clause.
If your code writes each text line before advancing one line, you can use AT END-OF-
PAGE phrase to detect that the program has already written the last line in the body of
the report page. If the page needs subtotals or column footings, you can specify a
number of footing lines in the LINAGE clause. This action causes the end-of-page
condition to arise when the process attempts to write into the footing area. You can
then use an AT END-OF-PAGE phrase in the main WRITE statement and specify that
when the end-of-page condition arises, a footing-area procedure is to be performed.
Example 30-4 illustrates this technique.
If you have trouble tracing the interactions of BEFORE phrases, AFTER phrases,
numbers of lines to advance, page advances, and channel skips, you can always
discover exactly what printer control commands are being used by following this
procedure:
1. Direct your output to a spooler collector with a fictitious location.
2. Use the PERUSE command LIST to specify that the lines for at least two pages be
listed to a printer or to the spooler collector in octal, showing all control codes:
LIST /OUT $S.#LPF/ 1/2 O C
This step lists each print line, each SETMODE operation, and each CONTROL
operation.
3. See the Spooler Programmer’s Guide to identify the codes in the SETMODE and
CONTROL operations.
Example 30-4. END-OF-PAGE Phrase
WRITE-PROCEDURE SECTION.
...
WRITE SHOW-LINAGE-REC BEFORE ADVANCING 1
AT END-OF-PAGE PERFORM DO-FOOTING.
...
DO-FOOTING.
MOVE SUMMATION-LINES TO SHOW-LINAGE-REC.
WRITE SHOW-LINAGE-REC BEFORE ADVANCING 2.
PERFORM COLLECT-SUBTOTALS-TO-PRINT.
WRITE SHOW-LINAGE-REC BEFORE ADVANCING PAGE.