COBOL Manual for TNS and TNS/R Programs
Language Elements
HP COBOL Manual for TNS and TNS/R Programs—522555-006
3-15
COBOL Words
•
A word can be defined as a paragraph-name more than once in a source program.
If more than one paragraph in the same section of a source program has the same
name, no statement anywhere in the program can refer to any of those paragraphs
by name.
If two or more sections of a source program each contains a paragraph with the
same paragraph-name, unqualified references to that paragraph-name are
acceptable only within such sections—all other references must be qualified. For
example, suppose sections S1 and S2 contain paragraphs named P. All references
to P in other sections must be qualified as P OF S1 or P OF S2. Without such
qualification, they cause the compiler to report an ambiguous reference.
Unqualified references made within S1 to P are assumed to refer to P OF S1, and
unqualified references made within S2 to P are assumed to refer to P OF S2.
Statements in S1 can refer to P OF S2 and statements in S2 can refer to P OF S1.
The word SECTION is not part of a section-name when used to qualify a
paragraph-name.
•
If a text-name is not a member of the default COPY library, it must be qualified by
its library-name each time a COPY statement mentions it.
•
If more than one file description entry in a program contains a LINAGE clause, the
special register LINAGE-COUNTER must be qualified by its file-name each time
the Procedure Division mentions it.
In Example 3-1, all data-names except PREFIX are unique.
Qualification is necessary to refer to either PREFIX item. For example, any of these
sentences would move the contents of one PREFIX to the other PREFIX:
MOVE PREFIX OF ITEM-NO TO PREFIX OF CODE-NO.
MOVE PREFIX IN ITEM-NO TO PREFIX OF MASTER-REC.
MOVE PREFIX OF TRANSACTION-REC TO PREFIX IN CODE-NO.
Example 3-1. Qualified Names
FD TRANSACTION-FILE
...
01 TRANSACTION-REC.
03 ITEM-NO.
05 PREFIX X(2).
05 CODE X(3).
03 QUANTITY S9(8).
...
01 MASTER-REC.
03 CODE-NO.
05 PREFIX X(2).
05 SUFFIX X(3).
03 DESCRIPTION X(70).