Record formats
Indexed files may contain records of fixed length (RECFORM=F) or variable length (RECFORM=V). In both of these formats, the records may be blocked or unblocked.In the COBOL compilation unit, the format of the records to be processed can be defined in the RECORD clause. The following table lists the phrases associated with each record format:
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) (format 3) |
Table 30: Specification of record formats in the RECORD clause
Access modes
Access to records of an indexed file may be sequential, random, or dynamic.
In the COBOL compilation unit, the access mode is defined by means of the ACCESS MODE clause. The following table lists the possible phrases together with their effect on the access mode.
ACCESS MODE clause | Access mode |
SEQUENTIAL | Sequential access: The records can be processed only in the order of their record keys. This means:
|
RANDOM | Random access: The records can be accessed in any order via their record keys. For this purpose, the (primary or secondary) key of the record to be processed must be supplied in the (ALTERNATE) RECORD KEY item prior to each I-O statement. |
DYNAMIC | Dynamic access: The records can be accessed sequentially and/or randomly. |
Table 31: Indexed files: ACCESS MODE clause and access mode