COBOL Manual for TNS and TNS/R Programs
Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs—522555-006
9-304
WRITE for Relative, Indexed, and Queue Files
•
Relative and Dynamic Access
For files of relative organization, the relative key data item must be set to the
desired record number before the WRITE occurs. This can be done in either of two
ways:
°
Set the key item to the relative record number.
°
Set the key item to -1 to have the record written at the end of the file or to -2 to
have the record written in any available file position.
When the second method is used, the relative key data item must be defined as a
signed integer numeric item; at the completion of the write operation, the relative
key data item is set to the file position number used.
For files of indexed organization, the program is responsible for setting the prime
record key data item to a desired value prior to the execution of a WRITE
statement for that record.
•
Invalid-Key Conditions
This condition occurs for relative files when any of these conditions is true:
°
The RELATIVE KEY item defines an existing record or the alternate key is
duplicated without DUPLICATES option (I-O status code “22”).
°
The file is physically full or the relative key data item points outside the file’s
boundary (I-O status code “24”).
°
The value intended for the RELATIVE KEY item does not fit into the RELATIVE
KEY item.
This condition occurs for indexed or queue files when any one of these is true:
°
Keys are not in ascending order in sequential access (I-O status code “21”).
°
The prime key is duplicated, or the alternate key is duplicated without
DUPLICATES option (I-O status code “22”).
°
The file is physically full, or the key specifies a point outside the file’s boundary
(I-O status code “24”).