Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

Permissible record formats and access modes

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...
or
RECORD CONTAINS...TO...

(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:

  • when reading records, the next or previous logical record is made available (for primary or secondary keys).

  • when writing records, the next logical record (with ascending primary key) is output to the file.

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.
The applicable access mode is selected via the format of the I-O statement in this case.

Table 31: Indexed files: ACCESS MODE clause and access mode