COBOL Manual for TNS/E Programs (H06.03+)
Procedure Division Verbs
HP COBOL Manual for TNS/E Programs—520347-003
9-31
CANCEL
identifier
is an alphanumeric, nonnational data item whose value (which is not known until
run time) is the program-name in the PROGRAM-ID paragraph of the COBOL
program to be cancelled.
Usage Considerations:
•
Internal Data Items Resume Their Initial Values
Each internal data item (except those in the Linkage Section) is reset to the value
that it had the first time the program was called. (CANCEL does not affect external
data items.)
•
Internal File Connectors Are Implicitly Closed
Each internal file connector whose open mode is neither closed nor locked is
implicitly closed. The implicit close operation proceeds as if a CLOSE statement
with no optional phrases were executed for each of the internal files. (CANCEL
does not affect external file connectors.)
If a called program that does not have the INITIAL attribute opens an internal file,
the file remains open until either:
°
The called program closes the file.
°
The calling program cancels the called program.
°
The process terminates.
•
PERFORM Statements Resume Their Initial State (Inactive)
•
GO TO Statements Modified by ALTER Statements Resume Their Initial Forms
Each GO TO statement that was modified by an ALTER statement is restored to
the form specified in the source program.
•
When Not to Use CANCEL
°
On programs compiled with the NOCANCEL directive
The NOCANCEL directive prevents the compiler from generating code that
initializes the program the first time the program is called after being canceled
by a CANCEL statement.
°
On programs that are still executing, including the main program
If you cancel the main program of the run unit or a called program that has not
returned control to its calling program, the run unit terminates abnormally with
a failure message.
°
On routines written in languages other than COBOL and called with X/Open
CALL statement
Applying a CANCEL statement to a routine written in a language other than
COBOL that was called with an X/Open CALL statement terminates the run
unit.










