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.
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 on the level-01 data definition for the
file status field.
Using an external file has these benefits:
- Even though 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 or READ.
- Each program has access to the file.
Example: using external files