WRITE for relative files

For relative record OUTPUT files, the WRITE statement causes actions as described in the topic.

  • If ACCESS IS SEQUENTIAL is specified:

    The first record released has relative record number 1, the second record released has relative record number 2, the third number 3, and so on.

    If the RELATIVE KEY is specified in the file-control entry, the relative record number of the record just released is placed in the RELATIVE KEY during execution of the WRITE statement.

  • If ACCESS IS RANDOM or ACCESS IS DYNAMIC is specified, the RELATIVE KEY must contain the required relative record number for this record before the WRITE statement is executed. When the WRITE statement is executed, this record is placed at the specified relative record number position in the file.

For I-O files, either ACCESS IS RANDOM or ACCESS IS DYNAMIC must be specified; the WRITE statement inserts new records into the file. The RELATIVE KEY must contain the required relative record number for this record before the WRITE statement is executed. When the WRITE statement is executed, this record is placed at the specified relative record number position in the file.