COBOL Manual for TNS and TNS/R Programs

Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs522555-006
9-302
WRITE for Relative, Indexed, and Queue Files
END-WRITE
ends the scope of the WRITE statement, causing the WRITE to be a delimited-
scope statement. If the WRITE statement does not end with an END-WRITE
phrase, the presence of the INVALID KEY or the NOT INVALID KEY phrase
causes the WRITE statement to be a conditional statement, which ends at the next
period separator.
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 relative or indexed organization, the order of the records in
the file is determined by the relative record number or the prime record key,
respectively.
In general, the logical record consists of the value of the data item specified by
record-name. Records in a relative, indexed, or queue file can be any length
from zero up to the maximum length specified when the file was created.
Release of a logical record does not necessarily imply immediate transmission to
the file. For example, the actual transmission of a logical record to the file can be
deferred until some time after completion of the WRITE statement.
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.
The I-O status codes that result from an unsuccessful write operation are:
I-O Status Code Unsuccessful Write Operation (page 1 of 2)
“21” The file is defined to have indexed organization and sequential
access mode, and the prime record key value of the logical
record is less than or equal to the prime record key value of the
most recently released record.
“22” One of:
The relative record number to be associated with the logical
record equals that of a record that already exists in the file
(random access or dynamic access only).
The prime record key value of the logical record equals that
of a record that already exists in the file (random access or
dynamic access only).
An alternate record key value of the logical record equals
that of a record that already exists in the file and duplicate
values are not allowed for that key all access modes.
“24” A boundary violation exception exists when execution of a
WRITE statement would require exceeding the record storage
capacity of the file. The logical record is not released.