EXTERNAL clause
The EXTERNAL clause specifies that the storage associated with a data item is associated with the run unit rather than with any particular program within the run unit.
An external data item can be referenced by any program in the run unit that describes the data item. References to an external data item from different programs using separate descriptions of the data item are always to the same data item. In a run unit, there is only one representative of an external data item.
The EXTERNAL clause can be specified only on data description entries whose level-number is 01. It can be specified only on data description entries that are in the WORKING-STORAGE SECTION of a program. It cannot be specified in LINKAGE SECTION, LOCAL-STORAGE SECTION, or FILE SECTION data description entries. Any data item described by a data description entry subordinate to an entry that describes an external record also attains the external attribute. Indexes in an external data record do not possess the external attribute.
The data contained in the record named by the data-name clause is external and can be accessed and processed by any program in the run unit that describes and, optionally, redefines it. This data is subject to the following rules:
- If two or more programs within a run unit describe the same external data record, each record-name of the associated record description entries must be the same, and the records must define the same number of bytes. However, a program that describes an external record can contain a data description entry including the REDEFINES clause that redefines the complete external record, and this complete redefinition need not occur identically in other programs in the run unit.
- Use of the EXTERNAL clause does not imply that the associated data-name is a global name.