COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
file-mnemonic
specifies the object file containing the program to be canceled. Associate file-mnemonic
with the operating system file name in the SPECIAL-NAMES paragraph of the Environment
Division (see SPECIAL-NAMES Paragraph (page 105)).
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.
◦ 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.
CHECKPOINT
NOTE: Do not use this directive in the OSS environment.
302 Procedure Division Verbs










