COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
• Two COBOL Programs With the Same Name
Two or more COBOL programs in a run unit can have the same program name. If this happens,
the compilation distinguishes between them according to these scope rules:
◦ If program A lacks the COMMON attribute and is directly contained in program B, then
only CALL statements in B can call A.
◦ If program A has the COMMON attribute and is directly contained in program B, then
only CALL statements in B and CALL statements in other programs contained in B (except
for A and those contained in A) can call A.
• Linking a Program Called With a CALL identifier Statement
Binding or linking a program called with a CALL identifier statement into a run unit is not
automatic. Verify that all such programs are bound or linked into the run unit by doing one
of:
◦ Compile all the program units in a single source file.
◦ Use the eld utility to link them into the run unit (see the eld Manual).
◦ Have each required program bound or linked into the run unit by referring to the program
explicitly in the source program with a dummy CALL statement and then calling the
program by an identifier.
◦ Use the SEARCH directive to add the program to the primary search list.
• Initial State of Called Programs
A program that has the INITIAL attribute is in its initial state every time it is called. Programs
directly or indirectly contained within a program that has the INITIAL attribute also have the
INITIAL attribute.
A program that does not have the INITIAL attribute is in its initial state the first time it is called,
but each successive time it is called, it is usually in the state in which its previous execution
left it. This state includes the final value of each internal data item (except those described in
the Linkage Section), the final status of each internal file connector, and the final status of each
GO TO statement whose destination procedure was specified by an ALTER statement.
A program that does not have the INITIAL attribute is not in the state in which its previous
execution left it if its calling program cancelled it with a CANCEL statement. In this case, the
called program is in its initial state the next time it is called. All PERFORM statements in the
program are restored to their initial states. All files are closed.
• Storage Allocation
For programs with the INITIAL attribute, HP COBOL uses dynamic storage allocation, allocating
space for data items in the Working-Storage Section each time the program is called and
releasing it each time the program is exited. This can cause stack overflow, which can cause
the run unit to terminate abnormally.
For programs without the INITIAL attribute, HP COBOL allocates space at the start of execution
of the run unit for all program data except internal data, which it allocates when the program
is called. It is unlikely that allocating space for internal data (usually a small amount) will cause
stack overflow.
• Passing Parameters
Parameters passed by the USING phrase are data items from a calling program that the called
program can reference.
298 Procedure Division Verbs










