If the LINKAGE TYPE phrase is not specified on the CANCEL statement, the type of program canceled can be changed by specifying one of: the LINKAGE TYPE clause of the SPECIAL-NAMES paragraph, or the LINKLIT parameter of the CRTCBLMOD or CRTBNDCBL command.
After a CANCEL statement for a called subprogram has been executed, that subprogram no longer has a logical connection to the program. The contents of data items in external data records described by the subprogram are not changed when a subprogram is canceled. If a CALL statement is executed later by any program in the run unit naming the same subprogram, that subprogram will be entered in its initial state.
A CANCEL statement closes all open INTERNAL files.
A CANCEL statement operates only on the program specified, and not on any program that may have been called by the canceled program.
Called subprograms may contain CANCEL statements. A called subprogram must not contain a CANCEL statement that directly or indirectly cancels its calling program or any other program higher than itself in the calling hierarchy. If a called subprogram attempts to cancel its calling program, the CANCEL statement in the subprogram is ignored.
A calls B and B calls C (When A receives control,
it can cancel C.)
A calls B and A calls C (When C receives control,
it can cancel B.)
No action is taken when a CANCEL statement is executed naming a program that has not been called in the run unit, or that names a program that was called and subsequently canceled. In both cases, control passes to the next statement.
See the IBM Rational Development Studio for i: ILE COBOL Programmer's Guide for more information on canceling procedures and program objects.