COBOL Manual for TNS and TNS/R Programs

Disk Input and Output
HP COBOL Manual for TNS and TNS/R Programs522555-006
28-14
Creating and Using HP COBOL Sequential Files
You can also read the file in key-value order. In this case, Enscribe does not report
absent records—it returns the records that exist. Because the key is part of the record,
you have access to the key value when you have read the record.
Enscribe allocates only as much space on disk as necessary for each key-sequenced
file record. Each record can vary in length from empty to the maximum record length
defined for the file. In HP COBOL terms, you can write fixed-length or variable-length
records (whichever the file was declared to have) of any length up to the limit. If
HP COBOL creates the file for you, that limit is the larger of:
The length of the longest record description entry for the file
The length declared in the RECORD CONTAINS clause
You can write records anywhere in the file, introducing new records or replacing
existing records. You can replace an existing record with a record of a different length.
You can delete a record. A deleted record is not the same as a record of length zero.
In HP COBOL, the DEPENDING phrase of the RECORD CONTAINS clause enables
you to designate a data item to receive the record length upon the successful
completion of a READ statement and to control the record length for a WRITE
statement. A read operation with an invalid key leaves the contents of the record area
undefined (that is, unpredictable).
Creating and Using HP COBOL Sequential
Files
In a sequential file—a file with sequential organization—records are arranged in a fixed
predecessor-successor relationship that is established as the records are entered in
the file.
HP COBOL sequential files fall into these categories:
Entry-Sequenced Files
Unstructured Files
Unstructured EDIT Files
HP COBOL programs can create, read, write, and purge all of the preceding forms of
sequential file. To create an entry-sequenced file that has alternate keys, however, the
COBOL program must use the FILE_CREATE_ procedure (see Unstructured Files).
Entry-Sequenced Files
An HP COBOL program can create and write an entry-sequenced file that any other
HP product can later read. An HP COBOL program can read an entry-sequenced file
created by any HP product.