COBOL Manual for TNS and TNS/R Programs

HP COBOL Manual for TNS and TNS/R Programs522555-006
30-1
30 Printer and Spooler Output
There are two ways that a process can write a report to paper: it can write directly to a
printer or it can write to a spooler collector.
When a process writes directly to a printer, it has exclusive use of the printer from the
time it opens the file until the time it closes the file.
When a process writes to a spooler collector, the spooler collector accumulates the
lines of the report on a disk and does not engage a printer until the process closes the
file.
Some installations insist that processes write only to a spooler, because this can even
out the printer usage or speed up jobs that would be output bound if they had to wait
for a slow printer.
An installation can configure its spooler locations such that a printer is either
accessible only to the spooler and never by other processes or accessible to other
processes whenever the spooler is not using it.
HP has no file structure that is strictly for printer files. To establish a COBOL file for use
with a printer, declare it to have sequential organization and to be accessed
sequentially.
Topics:
Using a Printer Directly
Understanding Spoolers
Using a Spooler
Controlling Vertical Spacing in a Printed Report
Formatting Pages of a Printed Report
Logging Program Activity Information to a Printer
Using a Printer Directly
Each installation chooses names for its printers. To write to a printer, an HP COBOL
program declares a file with sequential organization and sequential access and
associates that file with the printer device name.
The HP COBOL process tries to open the printer file with the open mode OUTPUT or
EXTEND. If the printer is not available, the OPEN statement fails with file status code
“30” and a run-time error. The HP COBOL run-time routines deliver a diagnostic
message to the process’ home terminal. If no declarative procedure is available for the
printer file, the process terminates. If a declarative procedure is available for the printer
file, the declarative procedure can examine the special register, GUARDIAN-ERR, and
take appropriate action.