Global and Local Names

Names can have global or local attributes. Some names are always global; other names are always local; and some names are either local or global depending upon specifications in the program in which the names are declared.

A program cannot reference any condition-name, data-name, file-name, index-name, paragraph-name, record-name, section-name, or type-name declared in any program it contains.

A global name may be used to refer to the object with which it is associated either from within the program in which the global name is declared or from within any other program which is contained in the program which declares the global name.

A local name, however, may be used only to refer to the object with which it is associated from within the program in which the local name is declared.

If a data-name, record-name, condition-name, type-name, or file-name is not declared to be global, the name is local.

Note: Specific rules sometimes prohibit specification of the GLOBAL clause for certain data description, file description, or record description entries.
constant-name
A constant-name is global if the GLOBAL clause is specified.
data-name
A data-name is global if the GLOBAL clause is specified either in the data description entry by which the data-name is declared or in another entry to which that data description entry is subordinate.
file-name
A file-name is global if the GLOBAL clause is specified in the file description entry for that file-name.
Two programs in a run unit can reference common file connectors in the following circumstances:
  1. An external file connector can be referenced from any program that describes that file connector.
  2. If a program is contained within another program, both programs can refer to a common file connector by referring to an associated global file-name declared either in the containing program or in any program that directly or indirectly contains the containing program.
record-name
A record-name is global if the GLOBAL clause is specified in the record description entry by which the record-name is declared or, in the case of record description entries in the File Section, if the GLOBAL clause is specified in the file description entry for the file-name associated with the record description entry.
condition-name
A condition-name, when declared in the data description entry, is global if that entry is subordinate to another entry in which the GLOBAL clause is specified.

A condition-name, when declared within the Configuration Section, is always global.

program-name
A program-name is neither local nor global. See Conventions for Program-Names.
section-name and paragraph-name
These names are always local.
library-name and text-name
These names are external to the program and can be referenced by any COBOL program, provided that the compiler system supports the associated library and the entities referenced are known to that system.
alphabet-name
An alphabet-name is always global.
class-name
A class-name is always global.
mnemonic-name
A mnemonic-name is always global.
index-name
If a data item possessing the global attribute includes a table accessed with an index, that index also possesses the global attribute. Therefore, the scope of an index-name is identical to that of the data-name which names the table whose index is named by that index-name and the scope of name rules for data-names apply. Index-names cannot be qualified.
IBM Extension
type-name
A type name is global if the GLOBAL clause is specified in the data description entry by which the type-name is declared. The GLOBAL attribute of a type-name is restricted to the type-name, and is not acquired by a data item that is defined using the type-name in a TYPE clause.
End of IBM Extension