Record formats
Relative files may contain fixed-length records (RECFORM=F) or variable-length records (RECFORM=V). In either case the records may be blocked or unblocked. COBOL compilation units permit the format of records to be processed to be declared in the RECORD clause. The phrases that are associated with the record format concerned are summarized in the following table:
Record format | Phrase in the RECORD clause | |
Fixed length records | RECORD CONTAINS...CHARACTERS | (Format 1) |
Variable length records | RECORD IS VARYING IN SIZE... | (Format 2) |
Table 25: Record format and RECORD clause
Access modes
Access to records of a relative file may be sequential, random, or dynamic.
In the COBOL compilation unit, the access mode is defined with the ACCESS MODE clause. The following table lists the possible phrases together with their effect on the access mode.
Phrase in the | Access mode |
SEQUENTIAL | Sequential access: The records can be processed only in the order in which they appear in the file. This order is determined by the relative record number. In other words: |
RANDOM | Random access: The records can be accessed in any order via the relative record number. |
DYNAMIC | Dynamic access: The records can be accessed sequentially as well as randomly. The applicable access mode is selected via the format of the I-O statement in this case. |
Table 26: ACCESS MODE clause and access mode