RELATIVE FILES:
The Files that are stored on a direct access storage medium like magnetic disk are frequently known as direct access files. The COBOL supports three different groups for disk files- sequential, relative & the index sequential.
A relative file is a magnetic-disk file organized in such a way that each record is identified by the relative record number. The relative record number identifies the position of the record from the starting of the file. Therefore the relative record number 1identifies the initial record, the relative record number 2 identifies the second record and so on.
A relative file can be access either successively or randomly. When the file is accessed successively the records are available in the increasing order of their relative record numbers. Whenever a file is accessed randomly, the programmer should specify the relative record number.
It may be noted that in the situation of relative organization, the reading and writing can be completed randomly. And hence, when a file is created by writing the record randomly, some of the record position may remain blank. While these positions can be filled in sub successively, the programmer must avoid specifying these empty positions while reading like relative file randomly. When a relative file is read in a sequential manner, then these empty places within it, if any, are ignored.
The handling of relative files needs some special codes in the FILE-CONTROL paragraph as well as in the PRCEDURE DIVISION.