Function
With the EXTERNAL clause, a file can be defined as external. External files can be accessed by any program in which the file is described.
Format
IS EXTERNAL
Syntax rule
Names of external files can have a maximum length of 30 characters.
General rules
If a file is defined as external, the records in that file are also implicitly external.
If the file description entry for a sequential file contains the LINAGE clause and the EXTERNAL clause, the LINAGE-COUNTER special register is implicitly an external data item.
The following may not be used as names for external files:
external record-names from the WORKING-STORAGE SECTION of other compilation units in the run unit,
PROGRAM-ID names of the run unit, except for program names of contained programs of a nested program,
names used as entry points in the ENTRY statement,
names that identify interfaces (LZS-name, etc.).
The effect of the FILE STATUS clause for external files is always local to the program, i.e. the file status is supplied only by I-O operations in the program that contains a corresponding specification in the file description entry.
The EXTERNAL clause may not be specified in file or record description entries for files that use a common I-O area (SAME RECORD AREA clause).
The EXTERNAL clause may not be specified for files that are assigned to the system devices SYSIPT, SYSOPT, PRINTER or PRINTERnn.
The EXTERNAL clause may not be specified for files for which user labels and corresponding USE procedures are defined.
An external file must be essentially described in the same manner via explicit clauses or implicit default values in all programs that wish to access the file. The following table shows how and to what extent the descriptions must match:
Clauses / specifications In all programs Name of external file same to full length (30 characters) OPTIONAL phrase (SELECT clause) same specification*) ASSIGN TO data-name same form of assignment ASSIGN TO PRINTER literal same form of assignment ORGANIZATION clause same form of organization ACCESS MODE clause same access method RELATIVE KEY phrase same number of digits RECORD KEY clause same length and position ALTERNATE RECORD KEY clause same number, position, length and DUPLICATES phrase BLOCK CONTAINS clause same block size in bytes MULTIPLE FILE TAPE clause same position number RECORD clause same minimum and maximum record length LABEL RECORDS clause same specification*) REPORT clause (Report Writer) same specification*) LINAGE clause same specification*) CODE SET clause same specification*) RECORDING MODE clause same specification*) *) Same specification means that the relevant clause may either be specified in none of the programs or must be specified the same in all programs.
All programs that access the same external file must have been compiled with the same value of the compiler option ENABLE-UFS-ACCESS or with the same module format (see the "COBOL2000 User Guide" [1]).
If a file is defined as external, this does not mean that the associated file-name is implicitly a global name.
Additional rules, depending on the module format
The following applies to the names of external files when generating the *OMF format (see the "COBOL2000 User Guide" [1]):
The eighth character must not be a hyphen.
Only the first 7 characters of the name are used for identification. These characters should therefore be unique for each external name in the run unit.