COBOL Manual for TNS/E Programs (H06.08+, J06.03+)

to an external object from different programs are always to the same object. In a run unit, there
is only one representation of an external object.
External and internal objects can have either global or local names.
Data Records in Working and Extended-Storage
To give a data record described in the Working-Storage or Extended-Storage Section the external
attribute, include the keyword EXTERNAL in its data description entry. Only record data description
entries can include the EXTERNAL clause. Any data item described by a data description entry
subordinate to an entry describing an external record also inherits the external attribute.
If a record or data item does not have the external attribute, it is part of the internal data of the
program that describes it.
File Connectors and Their Records
To give a file connector the external attribute, include the keyword EXTERNAL in its file description
entry. When a file connector has the external attribute, the records and the data items of the file
inherit the external attribute.
If a file connector does not have the external attribute, it is internal to the program that describes
the associated file-name.
The data records described subordinately to either of these file description entries are internal to
the program that describes the file-name unless the data records themselves are declared to be
external:
A file description entry that does not contain the EXTERNAL clause
A sort-merge file description entry
Any data items described subordinate to the data description entries for such records are also
internal to the program that describes the file-name.
Linkage Section Records
Data records and any subordinate data items in the Linkage Section are representatives of data
items defined in other programs. They are considered to be internal to the program describing
them and are directly accessible only to that program; however, they are indirectly accessible to
programs called by that program.
Shared Data
Two programs in a run unit can refer to common data in these circumstances:
Any program that has described an external data record can refer to the data content of that
record.
If program B is contained within program A, both programs can refer to data possessing the
global attribute and described in either:
The containing program A
Any program that directly or indirectly contains A
When a program passes a parameter value by reference, this establishes a common data
item—a storage location that each program can access. The called program can refer to a
data item in the calling program, using the same identifier or a different identifier.
If several programs define a data item as external (causing its storage location to be a single
location outside all programs) and they also define the data item as having a global name, then
all such programs and all programs nested within each of them have access to the data item.
Example 4 is a listing of a set of programs that share data through the global and external
mechanisms. Example 5 shows the output produced by executing the programs.
How Programs Share Resources 53