Data items and files defined in a program may be internal or external data.
Internal data can only be accessed within the program in which this data is defined.
External data can be accessed by any program in the run unit.
Internal data occupies a storage area associated exclusively with the particular program in which the data was defined. External data, on the other hand, occupies a storage area associated with the run unit. Data defined as external in the programs of a run unit can be accessed by all programs of the run unit.
External files and data items are created through specification of the EXTERNAL clause in the FILE SECTION or WORKING-STORAGE SECTION (see section "EXTERNAL clause" ).
Example 12-5
A run unit comprises three programs in which certain data is defined as external. The resulting storage occupancy is illustrated by the following diagram:
Storage area |
Storage area |
Storage area |
Storage area |
All internal data, i.e. data not defined as being external, is contained only in the storage area of the program in which it is defined. All data defined as external, on the other hand, is contained only in the storage area for external data.