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

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

(Format 2)

(Format 3)

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 clause

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:
When reading records, the next or previous record is made available.
When writing records, each successive record output to the file is assigned the next relative record number; no empty records are written.

RANDOM

Random access:

The records can be accessed in any order via the relative record number.
For this purpose, the relative record number of the record to be processed must be supplied in the RELATIVE KEY item prior to each I-O operation.

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