Sharing data by using the EXTERNAL clause
EXTERNAL clause to enable separately
compiled programs and methods (including programs in a batch sequence)
to share data items. Code
EXTERNAL in the level-01
data description in the
The following rules apply:
- Items that are subordinate to an
EXTERNALgroup item are themselves
- You cannot use the name of an
EXTERNALdata item as the name for another
EXTERNALitem in the same program.
- You cannot code the
VALUEclause for any group item or subordinate item that is
In the run unit, any COBOL program or method that has the same data description for the item as the program that contains the item can access and process that item. For example, suppose program A has the following data description:
01 EXT-ITEM1 EXTERNAL PIC 99.
Program B can access that data item if B has the
identical data description in its
program that has access to an
EXTERNAL data item
can change the value of that item. Therefore do not use this clause
for data items that you need to protect.