COBOL Manual for TNS/E Programs (H06.03+)

Disk Input and Output
HP COBOL Manual for TNS/E Programs520347-003
28-12
Structured Files
Topics:
Entry-Sequenced (Sequential) Files
Relative Files
Key-Sequenced (Indexed or Queue) Files
Entry-Sequenced (Sequential) Files
An entry-sequenced file created by an HP COBOL program is either a series of fixed-
length records or a series of variable-length records.
Your program ordinarily reads entry-sequenced files sequentially. You can read the
records in the order in which they appear in the file by opening the file for input and
reading record after record. You can append records to the file by opening the file with
an extension and writing records to the file.
Enscribe allows each physical record of an entry-sequenced file to have any length
from zero bytes (empty) to the maximum record length that was declared when the file
was created. HP COBOL allows each logical record to have any length from zero bytes
to the maximum record length declared explicitly in the file description entry or implicitly
in the record definitions following the file description entry.
If your source program describes the file as having variable-length records, each
physical record uses only as many bytes of disk space as needed; therefore, the
number of records for each block can vary according to the length of the records in
each block (although some space at the end of a block can be wasted).
If an entry-sequenced file has alternate keys, you can use a START statement to
specify the next record to read.
Relative Files
Relative files contain records that exist independent of each other. Each record is
associated with a unique relative record number—an ordinal number. The first record is
number 1, the second is number 2, and so forth. The number exists independent of the
contents of the record. You can read any record by number, but the record number is
not part of the record.
The record numbers of a relative file need not be consecutive; Enscribe does not
require that there be a record for each ordinal number between that of the first record
and the highest number associated with any record in the file. If the HP COBOL run-
time routines ask Enscribe for the record associated with a certain number and there is
no such record in the file, Enscribe reports that no such record exists, and the
HP COBOL run-time routine raises the invalid-key condition (and, if you defined a file
status code data item, the run-time routine stores an appropriate value in it).