Sharing files between programs (external files)
To enable separately compiled programs or methods in a
run unit to access a file as a common file, use the EXTERNAL
clause
for the file.
About this task
It is recommended that you follow these guidelines:
- Use the same data-name in the
FILE STATUS
clause of all the programs that check the file status code. - For each program that checks the same file status field, code
the
EXTERNAL
clause in the level-01 data definition for the file status field.
Using an external file has these benefits:
- Even if the main program does not contain any input or output statements, it can reference the record area of the file.
- Each subprogram can control a single input or output function,
such as
OPEN
orREAD
. - Each program has access to the file.