Uniqueness of Reference COBOL

Every user-defined name in a COBOL program is assigned, by the user, to name a resource that is to be used in solving a data processing problem. In order to use a resource, a statement in a COBOL program must contain a reference that uniquely identifies that resource.In order to ensure uniqueness of reference, a user-defined name may be qualified, subscripted or reference-modified as described in the following paragraphs.

When the same name has been assigned in separate programs to two or more occurrences of a resource of a given type, and when qualification by itself does not allow the reference in one of those programs to differentiate between the two identically named resources, then certain conventions which limit the scope of names apply. These conventions ensure that the resource identified is that described in the program containing the reference.

Unless otherwise specified by the rules for a statement, any subscripting and reference modification are evaluated only once as the first operation of the execution of that statement.

Qualification

Every user-defined name explicitly referenced in a COBOL source program must be uniquely referenced because either:

  • No other name has the identical spelling and hyphenation.
  • It is unique within the context of a REDEFINES clause.
  • The name exists within a hierarchy of names such that reference to the name can be made unique by mentioning one or more of the higher level names in the hierarchy.
  • These higher level names are called qualifiers and the process that specifies uniqueness is called qualification. Identical user-defined names may appear in a source program; however, uniqueness must then be established through qualification for each user-defined name explicitly referenced, except in the case of redefinition. All available qualifiers need not be specified so long as uniqueness is established. Reserved words naming the special registers require qualification to provide uniqueness of reference whenever a source program would result in more than one occurrence of any of these special registers. A paragraph-name or section-name appearing in a program may not be referenced from any other program.

  • A program is contained within a program or contains another program.

Regardless of the above, the same data-name must not be used as the name of an external record and as the name of any other external data item described in any program contained within ocontaining the program which describes that external data record. The same data-name must not be used as the name of an item possessing the global attribute and as the name of any other data item described in the program which describes that global data item.

An exception regarding the qualification requirement is made with respect to the operand of a REDEFINES clause because its position within the hierarchical structure of the Data Division implicitly supplies any qualification that might be needed.

In the hierarchy of qualification, names associated with a level indicator are the most significant, followed by names associated with level-number 01, followed by names associated with level-numbers 02, . . ., 49. The name of a conditional variable may be used as a qualifier for any of its condition-names.

Qualification is performed by following a data-name, condition-name, LINAGE-COUNTER, screen-name, split-key-name, or by one or more phrases made up of a qualifier preceded by IN or OF.IN and OF are logically equivalent.

Format 1:Qualification for Data-Names and Condition-Names

Qualification for Data-Names and Condition-Names

Format 2:Qualification for LINAGE-COUNTER

Qualification for LINAGE-COUNTER

Format 3:Qualification for Screen-Names

Qualification for Screen-Names

Format 4:Qualification for Split-Key-Names

Qualification for Split-Key-Names

The rules for qualification are as follows:

  1. Each reference in the Environment Division, the Data Division, or the Procedure Division to a nonunique user-defined word must be made unique by supplying a sequence of qualifiers that precludes any ambiguity of reference. An exception exists for paragraph-names referenced from the section in which they are defined within the Procedure Division as explained in the section “Procedure References”
  2. data-name-1 and data-name-2 may be record-names.
  3. Each qualifier must be a name associated with a level indicator (FD, SD or CD), a record-name (level 01), the name of a group item to which the item being qualified is subordinate, or the name of the conditional variable with which the condition-name is associated. All qualifiers must be within the same hierarchy as the name being qualified, and they must be specified in the order of successively more inclusive (higher) levels in the hierarchy.
  4. The same name must not appear at two levels in a hierarchy.
  5. A data-name cannot be subscripted when it is being used as a qualifier.
  6. In a program that contains more than one LINAGE clause, each reference to LINAGE-COUNTER must be qualified by the associated file-name.
  7. Each reference to a split-key-name, defined in a RECORD KEY or ALTERNATE RECORD KEY clause, must be qualified by the file-name of the file with which the split-key-name is associated if the split-key-name is not unique within the program.
  8. A name can be qualified even though it does not need qualification: if there is more than one combination of qualifiers that ensures uniqueness, any such set can be used. Qualified data-names may have any number of qualifiers up to a limit of 49.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

COBOL Topics