COBOL Manual for TNS and TNS/R Programs

Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs522555-006
9-204
REWRITE for Sequential, Relative, Indexed, and
Queue Files
°
When the file has variable-length records whose sizes are controlled by the
DEPENDING item specified in the RECORD clause (RECORD VARYING SIZE
DEPENDING name), the value of the DEPENDING item determines the size of
the logical record.
°
When the file has variable-length records but no DEPENDING item is specified
in the RECORD clause of the file description entry (RECORD CONTAINS m
TO n CHARACTERS), the size of the logical record is the size of the data item
referenced by record-name. If the data item has a variable size because it
contains a table that is described with an OCCURS DEPENDING clause, the
current size of the item is used.
When the file is described with the RECORD VARYING clause, the logical record
size must not be greater than the maximum or less than the minimum number of
character positions specified in that clause. (See I-O status code “44.”)
The content of the logical record released by the rewrite operation is the left-
justified value of the data item specified by record-name. If the logical record size
is greater than the data item’s size, the value is logically extended on the right with
arbitrary characters (that is, you cannot predict what the extending characters will
be). If the logical record size is less than the data items size, the value is logically
truncated on the right.
The execution of a REWRITE statement, whether successful or not, does not
normally affect the key of reference, the value of file position indicator, or the value
of the depending item specified in the DEPENDING phrase of the RECORD clause
associated with record-name ; however, the value of the file position indicator
can be left undefined in some cases when the I-O status is set to 30.
File-Status Data Item
If the file has an associated file-status data item, execution of the REWRITE
statement always assigns an appropriate I-O status code as its value. The status
“00” reports a successful rewrite operation with no duplicate alternate keys written.
The status code “02” reports a successful rewrite operation that created a duplicate
alternate key value for at least one alternate record key for which duplicates are
allowed (only when the file has the INSERTIONORDER attribute).
Note. The logical record released by a successful execution of the REWRITE statement is
no longer available in the record area unless the file name associated with record-name
is specified in a SAME RECORD AREA clause. The logical record is available to the
program as a record of other files referenced in the SAME RECORD AREA clause as the
associated output file, as well as the file associated with record-name.