COBOL Manual for TNS and TNS/R Programs

Disk Input and Output
HP COBOL Manual for TNS and TNS/R Programs522555-006
28-17
Creating and Using HP COBOL Indexed Files
The HP COBOL run-time routines that manipulate relative files convert HP COBOL
record numbers to Enscribe record numbers by subtracting 1 from the value of each
HP COBOL record number (except in the case of the two special record numbers -1
and -2 explained in Types of HP Disk Files).
If your HP COBOL program calls a TAL routine and passes a relative key to it or
receives a relative key from it, you must convert the record number appropriately.
Similarly, if a file contains numeric values that are to be used as record numbers, all
programs that use the file must use the same record numbering scheme.
These FUP commands declare the same relative file as the HP COBOL code in
Example 28-7:
SET TYPE R
SET EXT (1000 RECS, 2000 RECS)
SET REC 200
SET BLOCK 2048
CREATE $FIDDL.DEE.D
Creating and Using HP COBOL Indexed Files
In an indexed file—a file with indexed organization—records are accessed by the
values of a key field within each record.
An HP COBOL program can create and write an indexed file that any other HP product
capable of handling indexed files can later read. An HP COBOL program can read an
indexed file created by any HP product.
Example 28-7. Relative File Without Alternate Keys
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT RELFILE
ASSIGN TO "$FIDDL.DEE.D"
ORGANIZATION IS RELATIVE
ACCESS MODE IS RANDOM
RELATIVE KEY IS FIDLKEY.
...
DATA DIVISION.
FILE SECTION.
FD RELFILE
RECORD CONTAINS 5 TO 200 CHARACTERS
LABEL RECORDS ARE OMITTED.
01 REL-RECORD.
...
WORKING-STORAGE SECTION.
...
01 KEYS-GROUP.
03 FIDLKEY PIC 9(8) COMPUTATIONAL.