Relative files are generally used to store data where low overhead is required. Records are available by record number. On machines that directly support relative files (such as VMS), relative files are used.
On other machines (Windows and UNIX systems), relative files are treated the same as binary sequential files. Each record is physically located at its record number, and writing record 1 and record 1000 causes 999 blank records to be written. Block sizes are ignored, and each I/O uses the record size to determine how many bytes to transfer.
Records may be either fixed-length or variable-length. With variable-length records, if the maximum record size is equal to or less than 65,535 bytes, two bytes indicating record size (VLI) are placed in front of each variable-length record when it is written to disk. If the record size is larger than 65,535 bytes, four bytes are placed in front of each variable-length record. This two- or four-byte field is not specified in your COBOL program, but other non-COBOL programs that access the records need to be aware of the extra bytes. Each record is padded to the maximum size so that records can be retrieved randomly in an efficient fashion.
When a record is deleted, the physical record is filled with up to 256 null characters (LOW-VALUES in ACUCOBOL-GT). This deleted record marker can be changed through the use of the REL_DELETED_VALUE configuration variable. Note that ACUCOBOL-GT checks only the first 256 characters of the record to determine if it is deleted.
Relative files may be assigned only to disk files.
On many (but not all) systems, the runtime system allows a relative file to be opened for input when the user does not have write-access to the file.