COBOL Manual for TNS and TNS/R Programs

Source Program Organization and Format
HP COBOL Manual for TNS and TNS/R Programs522555-006
2-12
Scope of User-Defined Names
Program-Name
The PROGRAM-ID paragraph of a program’s Identification Division declares that
program’s program-name. Only the CALL and CANCEL statements and the END
PROGRAM statement can refer to a program-name. The program-names allocated to
programs constituting a run unit are not necessarily unique, but when two programs in
a run unit are identically named, at least one of those two programs must be directly or
indirectly contained within another separately compiled program that does not contain
the other of those two programs.
These rules regulate the scope of a program-name:
If the program-name, X, is that of a program that does not have the common
attribute and is directly contained within another program, Y, then only statements
included in Y can refer to X.
If the program-name, V, is that of a program that does have the common attribute
and is directly contained within another program, W, then any programs directly or
indirectly contained within W can reference V; however, program V and any
programs contained within V cannot refer to V (because V calling V is recursion,
and because V cannot cancel itself).
If the program-name, U, is that of a separately compiled program, then U can be
referenced by statements included in any other program in the run unit, except
programs it directly or indirectly contains. HP COBOL programs that are compiled
at the same time but separated by the ENDUNIT directive or by an END
PROGRAM statement are called separately compiled, as if they had been
compiled by different executions of the compiler.