Function
With the EXTERNAL clause, a record can be defined as external. External files and records can be accessed by any program in which the file or record is described.
Format for file description entries
IS EXTERNAL
Syntax rules
The EXTERNAL clause may be included only in the record description entry of the WORKING-STORAGE SECTION.
A data-name declared as external may not be declared again within the same program.
The EXTERNAL clause may refer only to a data description entry with level number 01.
Names of external records can have a maximum length of 30 characters.
The following must not be used as the name of an external record:
names of external files from other compilation units in the run unit
PROGRAM-ID names of the run unit, except names of contained programs in a nested program
names used as entry points in an ENTRY statement
names which identify interfaces (LZS-name, etc.).
The EXTERNAL clause and the REDEFINES clause must not be used together in the same data description entry.
The EXTERNAL clause and the TYPEDEF clause may not be used in the same data description entry.
The EXTERNAL clause may not be specified for a data item of the class “object”, “pointer” or "strongly typed".
General rules
An external record that is described in several programs of a run unit must have the same name in each of these programs and must also have the same length. The compiler permits the use of different length definitions, but this possibility should not be used if CALL identifier is used in the program.
If a record is defined as external, the associated file is not implicitly an external file.
VALUE clauses which are specified in a data description which is assigned or subordinate to a data description with EXTERNAL clause are only meaningful when an INITIALIZE statement is executed.
If, in more than one program, VALUE clauses are assigned or subordinate to an external record which is defined in several programs of a run unit, these VALUE clauses must be identical. The compiler also permits different VALUE clauses.
Additional rules, depending on the module format
The following applies to the name of any external record when generating the *OMF format (see the "COBOL2000 User Guide" [1]):
The eighth character must not be a hyphen.
Only the first 8 characters of the name are used for identification. These characters should therefore be unique for each external name in the run unit.