COBOL Manual for TNS and TNS/R Programs
Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs—522555-006
9-205
REWRITE for Sequential, Relative, Indexed, and
Queue Files
The rewrite operation cannot succeed if the device associated with the file is not a
disk device.
The possible I-O status codes for an unsuccessful rewrite are:
Note. After an unsuccessful execution of a REWRITE statement, these values are
unpredictable:
•
The value of the file position indicator
•
The contents of the current record area
•
The key of reference
Any key value found in the current record area: that is, the value of the current key for
indexed files or the value of the alternate key for any type of file-system file, because in
HP COBOL sequential and relative files can have alternate keys.
I-O Status Code Unsuccessful Rewrite (page 1 of 2)
“21” The file’s access mode is sequential, the file organization is
indexed, and the prime record key value of the logical record is not
equal to the value of the prime record key of the last record read.
The invalid-key condition arises.
“22” One of the alternate key values in the logical record is equal to the
value of that key in a record that already exists in the file, and the
DUPLICATES phrase is not specified for that key. The invalid-key
condition arises.
“23” The file’s access mode is random or dynamic, and the specified
relative key value or prime record key value does not correspond to
that of any record existing in the file. The invalid-key condition
arises.
“30” The rewrite operation failed due to non-COBOL causes. The
specified record might or might not have been rewritten. The run-
time routines always return this status when the file is not assigned
to a disk, in which case nothing is rewritten. The value of the file
position indicator can be left undefined in some cases when the I-O
status code is “30.”
Whenever the rewrite operation terminates with an I-O status code
greater than or equal to “30,” execution of the REWRITE statement
is unsuccessful. In this case, the applicable USE procedure, if any,
is executed.