HP 3000 Manuals

Uniqueness of Reference [ HP COBOL II/XL Reference Manual ] MPE/iX 5.0 Documentation


HP COBOL II/XL Reference Manual

Uniqueness of Reference 

To ensure that the basic elements defined in the various program
divisions can be properly referenced in the PROCEDURE DIVISION, the
compiler places several restrictions on some of these elements.  These
restrictions cover qualifiers, subscripts, indexes, and identifiers as
they apply to data names, condition names, paragraph names, and text
names.

Qualifiers 

Each data name, condition name, paragraph name, and text name must be
unique within the program in which it appears.  Such a name is unique if
either of the following conditions applies:

   *   No other name in the program has the same spelling and
       hyphenation.

   *   If the same name is used for two different elements in a program,
       it must be made unique through qualification.  For instance, if
       two paragraphs are both identified by the name PAR-MSG, they must
       be members of different sections, called perhaps SEC-1 and SEC-2.
       In the PROCEDURE DIVISION, you might then reference one of these
       paragraphs by specifying:

     PAR-MSG OF SEC-1.

In a hierarchy of names such as this, the higher-level names are called
qualifiers.  Specifically, a qualifier is one of the following:

   *   A data name used in a reference together with another data name or
       with a condition name at a lower level in the same hierarchy.

   *   A section name used in a reference together with a paragraph name
       specified in that section.

   *   A library name used in a reference together with a text name
       associated with that library.

In a program, you qualify a data name, condition name, paragraph name, or
text name by entering one or more phrases composed of the following:  the
name to be qualified, followed by the reserved word IN or OF, followed by
a qualifier.  Four formats are possible, depending on the type of name:

[]
[]

NOTE In these format descriptions, the keywords OF and IN are logically equivalent and can be used interchangeably.
In all cases, you must use sufficient qualifiers to make the name unique. It is not always necessary, however, to mention all levels in a particular hierarchy. Within the DATA DIVISION, all data names used as qualifiers must be associated with a level indicator or level number. Thus, you cannot specify two identical data names as subordinate entries in a group item unless you can make them unique through qualification. In the qualification hierarchy, names associated with a level indicator are the most significant; names associated with level number 01 are the next most significant; names associated with level numbers 02 through 49 are then ranked in descending order of significance. In the PROCEDURE DIVISION, two identical paragraph names must not appear in the same section. A section name is the highest and only qualifier for a paragraph name.
NOTE The most significant name in any hierarchy must be unique and cannot be qualified.
Subscripted or indexed data names and conditional variables can be made unique through qualification. The name of a conditional variable can be used as a qualifier for any of its condition names. Regardless of the available qualification, no name can be both a data name and a procedure name. In using qualification, the following specific rules apply: For all names: * You must make sure that each qualifier belongs to a successively higher level and falls within the same hierarchy as the name it qualifies. * You cannot use the same name at two or more levels in the same hierarchy. * You can use any combination of qualifiers to reference the name if more than one combination of qualifiers ensures uniqueness. * You can qualify a name even if it does not require qualification. For data names and condition names: * If you assign a data name or condition name to more than one data item, you must qualify this name each time it is referenced in the ENVIRONMENT, DATA, and PROCEDURE divisions.
NOTE This rule does not apply to the REDEFINES clause of the DATA DIVISION, where qualification is prohibited.
For data names: * You cannot subscript a data name that is used as a qualifier. * You cannot specify, as the complete set of qualifiers for one data name, a partial set of qualifiers used for another data name. * You must qualify data names if more than one file contains a LINAGE clause. For paragraph names: * You cannot duplicate a paragraph name within a section. * You cannot use the reserved word SECTION in the qualification of a paragraph when the paragraph name is qualified by a section name. * You need not qualify a paragraph name that is referenced within the same section. For text names: * You must qualify all text names each time they are referenced in the program if more than one COBOL library is used during compilation. Example The following example illustrates qualification. The name DATA-GRAY is duplicated in the program, where it actually refers to two different data items. In each case, the name can be qualified as DATA-GRAY OF DATA-BLACK or DATA-GRAY OF DATA-GREEN. DATA DIVISION. : 01 RECORD-1. 03 DATA-BLACK. 05 DATA-GRAY. 10 DATA-BLUE PIC X(06). 10 DATA-YELLOW PIC X(06). 05 DATA-BROWN PIC X(12). 03 DATA-WHITE. 05 DATA-GREEN. 10 DATA-GRAY PIC X(06). :


MPE/iX 5.0 Documentation