Types of names
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 defined.
- 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 defined
- From within any other program that is contained in the program that defines 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 defined.
By default, if a data-name, a file-name, a record-name, or a condition-name definition in a data description entry does not include the GLOBAL clause, the name is local.
- For methods
- All names defined in methods are implicitly local.
- For classes
- Names defined in a class definition are global to all the methods contained in that class definition.
- For object paragraphs
- Names defined in the DATA DIVISION of an object paragraph are global to the methods contained in that object paragraph.
- For factory paragraphs
- Names defined in the DATA DIVISION of a factory paragraph are global to the methods contained in that factory paragraph.
- For user-defined functions
- All names defined in user-defined functions are local.
- For function prototypes
- All names defined in function prototypes are local.
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 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 defines the data-name or in another entry to which that data description entry is subordinate.
- 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 assigns
a name to a record.
A record-name is global if the GLOBAL clause is specified in the record description that defines 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 associates
a value with a conditional variable.
A condition-name that is defined 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 defined within the configuration section is always global.
- 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 assigns a name to a method. method-name must be specified as the content of an alphanumeric literal or a national literal.
- section-name assigns
a name to a section in the PROCEDURE DIVISION.
A section-name is always local.
- paragraph-name assigns
a name to a paragraph in the PROCEDURE DIVISION.
A paragraph-name is always local.
- 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 specifies the COBOL library that the compiler uses for including COPY text. For details, see COPY statement.
- 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 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 assigns
a user-defined word to an implementer-name.
A mnemonic-name is always global.
specifies a user-defined figurative constant.
A symbolic-character is always global.
- 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.
- xml-schema-name assigns
a name to the system identifier of a file containing an XML schema.
An xml-schema-name is always global.