COBOL Manual for TNS/E Programs (H06.03+)

Program Execution
HP COBOL Manual for TNS/E Programs520347-003
12-24
Called Program Termination
When a called program that has the initial attribute terminates its own execution, an
implicit CANCEL statement referencing the program is executed just after control
passes from the called program. This causes the value of each internal data item to
become undefined and performs an implicit close operation for each internal file
connector that is not closed (with or without lock). The implicit close operations
proceed as if a CLOSE statement without any of the optional phrases were executed
for each of the affected files. If the program is called again, it is placed in its initial
state.
When a called program that does not have the initial attribute terminates its own
execution, each internal entity (except a data item described in the Linkage Section)
retains its status:
Each internal data item (except those described in the Linkage Section) retains its
current value.
Each internal file connector retains all of its current dynamic attributes; therefore, if
it is open in some mode, it remains open in that mode and the record area for the
file associated with the internal file connector retains its current contents.
Each GO TO statement modified by execution of an ALTER statement retains the
last destination procedure specified.
If the program is called again during this execution of the run unit, its state upon entry
is normally unchanged from the state in which its termination logic left it, except that
those data items described in the Linkage Section have whatever values are supplied
by the calling program; however, if a CANCEL statement designating the program is
executed after the program terminates, it causes the value of each internal data item to
become undefined and performs an implicit close operation for each internal file
connector that is neither closed nor locked. The implicit close operations proceed as if
a CLOSE statement without any of the optional phrases were executed for each of the
affected files. In this case, the program is placed in its initial state the next time it is
called.