COBOL Manual for TNS and TNS/R Programs

Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs522555-006
9-303
WRITE for Relative, Indexed, and Queue Files
Variable-Length Records
An Enscribe structured file can have variable-length records. See READ for
Sequential or Dynamic Access.
When you write to a file that is defined as having variable-length records, the
length of the record written depends on whether the file is declared with
RECORD CONTAINS rec-1 TO rec-2 CHARACTERS
or
RECORD IS VARYING IN SIZE FROM rec-1 TO rec-2 CHARACTERS
DEPENDING ON rec-size
form of the RECORD CONTAINS clause.
In the former case, the length of the record specified in the WRITE statement is the
number of characters written to the file system file.
In the latter case, the length of the record written is the value present in the rec-
size data item specified in the DEPENDING clause at the time the WRITE
statement is executed.
Sequential Access
For files of relative organization, records are released in relative number order,
beginning at 1. When the file has an associated relative key data item, that item is
set to the current record number at each successful release.
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. In the case of sequential access, the records must be
released in ascending order of prime record key value.
“30 The write operation failed due to non-COBOL causes. The
specified record might or might not have been written.
“44” When the file is described with the RECORD VARYING clause,
the logical record size must be neither greater than the maximum
nor less than the minimum number of character positions
specified in that clause. This requirement is not met, and the
logical record is not released.
“48” Either the file has sequential organization, and is not open in I-O,
OUTPUT, or EXTEND mode; or the open mode is I-O, and the file
device is not a terminal, process, or $RECEIVE.
I-O Status Code Unsuccessful Write Operation (page 2 of 2)