COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
The program makes them accessible to the other programs by declaring them to be external. Any
other program in the run unit can use them by likewise declaring them to be external. (The opposite
of external is internal. Internal objects are only accessible to the program that declares them—or,
if they have global names, to programs within that program—and only one program can declare
them.)
Topics:
• Global and Local Names
• External and Internal Objects
• Shared Data
• Shared Files
Global and Local Names
A data-name (which names a data item) or a file-name (which names a file connector) can be
either global or local.
Suppose that program X declares data-name Y, and program X contains program Z, which also
declares data-name Y. When program Z references data-name Y, it is referencing the Y that it
declared, not the Y that program X declared, whether program X declared its Y to be global or
not.
Some names are always global; other names are always local; and some names are either global
or local, depending on specifications in the program that declares the names:
It is global if a GLOBAL clause is in …Name
its record description entry or the file description entry for the file-name associated
with its record description entry (if the record-name is in the File Section)
Record-name
its record description entryData-name
an entry to which its data description entry is subordinate (that is, if a data-name
is declared global, all condition-names subordinate to it are automatically global)
Condition-name
its file description entryFile-name
In some circumstances, a data description, file description, or record description entry cannot
specify the GLOBAL clause (see GLOBAL Clause (page 191)).
If a data-name, file-name, or condition-name declared in a data description entry is not global,
the name is local.
Global names are inherited by contained programs. Suppose program OUTER declares a name
X to be global and contains program INNER, which contains program INNERMOST. As long as
program INNER does not define the name X explicitly, a reference to X in INNER refers to the X
defined in OUTER. Also, as long as program INNERMOST does not define the name X and program
INNER does not define X as a global name, a reference to X in INNERMOST refers to the X defined
in OUTER.
Global names, as well as local names, can be associated with external and internal objects.
External and Internal Objects
An external object is stored in an area that is associated with the run unit rather than with any
particular program within the run unit.
An internal object is stored in an area that is associated only with the program that describes the
object.
An external object can be referenced by any program in the run unit that describes the object. All
such descriptions must be identical, or the results of the references are unpredictable. References
52 Source Program Organization and Format










