COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
Usage Considerations:
• Action of the WRITE Statement
The write operation releases a logical record to the run-time routines for inclusion in the file.
For a file of sequential organization, the order of the records in the file therefore corresponds
to the order in which they are released.
In general, the logical record consists of the value of the data item specified by record-name;
however, when the file has fixed-length records, and the record-name item contains fewer
than the defined number of character positions, the logical record is extended with arbitrary
character values.
• Printer or Spooler Files
Release of a logical record does not necessarily imply immediate transmission to the file. The
record can be held in an internal buffer. The logical record is always transmitted to the file
or spooler buffer immediately.
• Opening File Positions Printer at Top of First Page
When you open a file, the printer is positioned at the top of the first page, as if BEFORE
ADVANCING PAGE had been executed. If you use default advancing (AFTER ADVANCING
1), you get a blank line at the top of the first page. (You usually use BEFORE 1 before the first
write operation.)
• Files That Are Not Printers or Spooler Files
If a file is not a printer or spooler file, each logical record is written to the file immediately,
any ADVANCING clause is ignored, and no control information (for advancing or forms
control) or extra blank lines are written to the file.
• Writing to EDIT Files
An HP COBOL program can write at most 239 characters to an EDIT file (a file with file code
101). The action of the WRITE statement depends on the existence of the file and on the form
of OPEN used.
◦ Existing EDIT file, OPEN EXTEND
Each write operation appends a line to the file. The line numbers of the new lines begin
at a value one greater than the last line number in the file, and are incremented by one.
◦ Existing EDIT file, OPEN OUTPUT
Existing records are deleted from the file. Each write operation appends a line to the file.
Line numbers begin at one and are incremented by one.
◦ File does not exist, OPEN OUTPUT or EXTEND
For the write operation to create the file, the run-time environment must contain an ASSIGN
command that specifies CODE 101. Each write operation appends a line to the file. Line
numbers begin at one and are incremented by one.
To make the file an EDIT file before writing it, use the COBOL_ASSIGN_ routine with
file-code 101.
◦ Program was compiled with the NONSTOP directive
If a program was compiled with the NONSTOP directive, it can open an EDIT file for
input, but not for either form of output.
• File-Status Data Item
If the file has an associated file-status data item, execution of the WRITE statement always
assigns an appropriate I-O status code. The value “00” reports a successful write operation.
490 Procedure Division Verbs










