COBOL Manual for TNS and TNS/R Programs

Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs522555-006
9-33
CANCEL
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.
°
Within programs that are to run as process pairs
If the primary process of a process pair executes a CANCEL statement, the
backup process can become invalid.