Conventions for Condition-names, Data-names, File-names, Record-names, Report-names and Typedef-names

When condition-names, data-names, file-names, record-names and report-names

and typedef-names

are declared in a source element, they can be referenced only by that source element unless one or more of the names is global and the source element contains other source elements.

The requirements governing the uniqueness of the names declared by a single source element to be condition-names, data-names, file-names, record-names and report-names

and typedef-names

are explained in the discussion of user-defined words in the section COBOL Words.

A source element cannot reference any condition-name, data-name, file-name, record-name or report-name

or typedef-name

declared in any source element it contains.

A global name can be referenced in the source element in which it is declared or in any source elements which are directly or indirectly contained within that source element.

When a source element, source element B, is directly contained within another source element, source element A, both source elements can define a condition-name, a data-name, a file-name, a record-name or a report-name

or a typedef-name

using the same user-defined word. When such a duplicate-name is referenced in source element B, the following rules are used to determine the referenced item:

  1. The set of names to be used for determination of a referenced item consists of all names that are defined in source element B and all global names that are defined in source element A and in any source elements which directly or indirectly contain source element A. Using this set of names, the normal rules for qualification and any other rules for uniqueness of reference are applied until one or more item is identified.
  2. If only one item is identified, it is the referenced item.
  3. If more than one item is identified, no more than one of them can have a name local to source element B. If zero or one of the items has a name local to source element B, the following rules apply:
    1. If the name is declared in source element B, the item in source element B is the referenced item.
    2. Otherwise, if source element A is contained within another source, the referenced item is:
      1. The item in source element A if the name is declared in source element A.
      2. The item in the containing source element if the name is not declared in source element A and is declared in the source element containing source element A. This rule is applied to further containing source elements until a single valid name has been found.