In addition to identifying a resource, a name can have global or local attributes.
Some names are always global, some names are always local, and some names are either
local or global depending on specifications in the program in which the names are
declared.
- For programs
- A global name can be used to refer to the resource with which it is associated
both:
- From within the program in which the global name is declared
- From within any other program that is contained in the program that declares the
global name
Use the GLOBAL clause in the data description entry to indicate that a name is global.
For more information about using the GLOBAL clause, see GLOBAL clause.
A local name can be used only to refer to the resource with which it is associated
from within the program in which the local name is declared.
By default, if a data-name, a file-name, a record-name, or a condition-name
declaration in a data description entry does not include the GLOBAL clause, the name is
local.
- For methods
- All names declared in methods are implicitly local.
- For classes
- Names declared in a class definition are global to all the methods contained in that
class definition.
- For object paragraphs
- Names declared in the data division of an object paragraph are global to the methods
contained in that object paragraph.
- For factory paragraphs
- Names declared in the data division of a factory paragraph are global to the methods
contained in that factory paragraph.
Restriction: Specific rules sometimes prohibit specifying the GLOBAL
clause for certain data description, file description, or record description entries.
The following list indicates the names that you can use and whether the name can be
local or global:
- data-name
- data-name assigns a name to a data item.
A data-name is global if the GLOBAL clause is specified either in the data description
entry that declares the data-name or in another entry to which that data description
entry is subordinate.
- file-name
- file-name assigns a name to a file connector.
A file-name is global if the GLOBAL clause is specified in the file description entry
for that file-name.
- record-name
- record-name assigns a name to a record.
A record-name is global if the GLOBAL clause is specified in the record description
that declares the record-name, 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
- condition-name associates a value with a conditional variable.
A condition-name that is declared in a data description entry is global if that entry
is subordinate to another entry that specifies the GLOBAL clause.
A condition-name that is declared within the configuration section is always
global.
- program-name
- program-name assigns a name to an external or internal (nested) program. For
more information, see Conventions for program-names.
A program-name is neither local nor global. For more information, see Conventions for program-names.
- method-name
- method-name assigns a name to a method.
method-name must be specified as the content of an
alphanumeric literal or a national
literal.
- section-name
- section-name assigns a name to a section in the procedure division.
A section-name is always local.
- paragraph-name
- paragraph-name assigns a name to a paragraph in the procedure division.
A paragraph-name is always local.
- basis-name
- basis-name specifies the name of source text that is be included by the
compiler into the source unit. For details, see BASIS statement.
- library-name
- library-name specifies the COBOL library that the compiler uses for including
COPY text. For details, see COPY statement.
- text-name
- text-name specifies the name of COPY text to be included by the compiler into
the source unit. For details, see COPY statement.
- alphabet-name
- alphabet-name assigns a name to a specific character set or collating
sequence, or both, in the SPECIAL-NAMES paragraph of the environment division.
An alphabet-name is always global.
- class-name (of data)
- class-name assigns a name to the proposition in the SPECIAL-NAMES paragraph of
the environment division for which a truth value can be defined.
A class-name is always global.
- class-name (object-oriented)
- class-name assigns a name to an object-oriented class or subclass.
- mnemonic-name
- mnemonic-name assigns a user-defined word to an implementer-name.
A mnemonic-name is always global.
- symbolic-character
- symbolic-character specifies a user-defined figurative constant.
A symbolic-character is always global.
- index-name
- index-name assigns a name to an index associated with a specific table.
If a data item that possesses the global attribute includes a table accessed with an
index, that index also possesses the global attribute. In addition, the scope of that
index-name is identical to the scope of the data-name that includes the table.