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.

Read syntax diagramSkip visual syntax diagram
EXTERNAL Clause - Format

>>-+----+--EXTERNAL--------------------------------------------><
   '-IS-'             

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 representation of an external data item.

The EXTERNAL clause can be specified in either 01 level entries in the Working-Storage Section or in file description entries. If there are two data description entries with the same data name in the same Data Division, only one entry can contain the EXTERNAL clause. Index-names, condition-names, and renaming (level-66) items 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 standard data format characters. 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.
  • The VALUE clause must not be used in any data description entry which includes, or is subordinate to an entry which includes, the EXTERNAL clause. The VALUE clause can be specified for condition-name entries associated with such data description entries.
  • The TYPEDEF clause cannot be specified in the same data description entry as the EXTERNAL clause.

See Data Reference and Name Scoping for more information.