COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
EDIT Files
An EDIT file is a special form of unstructured file whose file code is 101. HP COBOL programs
can read, write, and create EDIT files. The file code 101 must be assigned to the file in one of
these ways before the HP COBOL program opens the file:
• Create the file outside the program (with an HP editor or FUP).
• Have the HP COBOL program create the file by calling the FILE_CREATE_ procedure.
• Before executing the HP COBOL program, use the TACL command ASSIGN to associate the
file’s name with the file code 101.
• Have the program call the routine COBOL_ASSIGN_ to associate the file’s name with the file
code 101.
Creating and Using HP COBOL Relative Files
In a relative file—a file with relative organization—records are accessed by their record numbers.
A record number is the position, relative to the beginning of the file, at which the record is stored.
It is not related to the order in which the records were entered in the file. Record numbers need
not be consecutive; for example, you can create a relative file with only three records whose
numbers are 12, 19435, and 237.
An HP COBOL program can create and write a relative file that any other HP product can later
read. An HP COBOL program can read a relative file created by any HP product.
An HP COBOL program can create, read, write, and purge relative files. An HP COBOL program
must use the FILE_CREATE_ procedure to create a relative file that has alternate keys.
An HP COBOL program cannot create a relative file that has alternate keys directly, because the
operating environment maintains the alternate keys in one or more separate files whose names
are recorded with the operating environment information about the relative file (see Alternate
Record Keys).
An HP COBOL program can create a relative file that does not have alternate keys simply by
describing the file as having relative organization (but without alternate keys) and opening the file
for OUTPUT, EXTEND, or I-O. The HP COBOL run-time routines create the relative file.
There is one important difference between the way HP COBOL uses relative files and the way
many other HP utilities use them: HP COBOL calls the first record in a relative file record 1, and
the operating environment and most other HP software call the first record in a relative file record
0.
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 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.
Example 282 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.
866 Disk Input and Output










