COBOL Manual for TNS and TNS/R Programs

Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs522555-006
9-206
REWRITE for Sequential, Relative, Indexed, and
Queue Files
Access Mode and REWRITE
°
Sequential-access files
When a sequential file has variable-length records, the number of character
positions in the logical record specified by record-name must be equal to the
number of character positions in the record being replaced. If this is not so, the
rewrite operation is unsuccessful and terminates with I-O status code “44.”
When the access mode of the file affected by the rewrite operation is
sequential, the last input-output statement executed for the file must have been
a successful READ statement. If it was not, the record is not released and the
rewrite operation terminates with the I-O status code “43;” otherwise, the
rewrite operation logically replaces the record that was accessed by the READ
statement; therefore, for an indexed or queue file, the program logic must verify
that the prime record key in the logical record has the same value as the prime
record key of the record previously read.
°
Random-access or dynamic-access files
For relative files with random or dynamic access, the record replaced is the
one indicated by the value of the RELATIVE KEY item. If the old record does
not exist, an invalid-key condition occurs.
For indexed files with random or dynamic access or for files being accessed
through alternate keys using random or dynamic access, the prime record key
data item (the RECORD KEY item) selects the old record to be replaced. The
value of alternate keys can differ in the new records, unless this would create
duplicate key values for a key whose values must be unique.
“43” The access mode is sequential, and the last input or output
statement executed for the file was not a successful READ
statement. The record is not released.
“44” There are two possibilities:
The file is described with the RECORD VARYING clause, and
the logical record size is greater than the maximum or less than
the minimum number of character positions specified in that
clause. The logical record is not released.
The file is a sequential file described with the RECORD
VARYING clause, and the size of the logical record is not equal
to the size of the record being replaced. The logical record is
not released.
“49 The file is not open in I-O mode. The rewrite operation terminates
immediately.
I-O Status Code Unsuccessful Rewrite (page 2 of 2)