Rational Developer for System z
COBOL for Windows, Version 7.5, Language Reference


CANCEL statement

The CANCEL statement ensures that the referenced subprogram is entered in initial state the next time that it is called.

Format
Read syntax diagramSkip visual syntax diagram           .------------------.  
           V                  |  
>>-CANCEL----+-identifier-1-+-+--------------------------------><
             '-literal-1----'    
 
identifier-1, literal-1
literal-1 must be an alphanumeric literal. identifier-1 must be an alphanumeric, alphabetic, or zoned decimal data item such that its value can be a program-name. The rules of formation for program-names are dependent on the PGMNAME compiler option. For details, see the discussion of program-names in PROGRAM-ID paragraph and the description of the PGMNAME compiler option in the COBOL for Windows Programming Guide.

identifier-1 cannot be a windowed date field.

literal-1 or the contents of identifier-1 must be the same as a literal or the contents of an identifier specified in an associated CALL statement.

Do not specify the name of a class or a method in the CANCEL statement.

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 that subprogram is canceled. If a CALL statement is executed later by any program in the run unit naming the same subprogram, that subprogram is entered in its initial state.

When a CANCEL statement is executed, all programs contained within the program referenced in the CANCEL statement are also canceled. The result is the same as if a valid CANCEL were executed for each contained program in the reverse order in which the programs appear in the separately compiled program.

A CANCEL statement closes all open files that are associated with an internal file connector in the program named in an explicit CANCEL statement. USE procedures associated with those files are not executed.

You can cancel a called subprogram in any of the following ways:

No action is taken when a CANCEL statement is executed if the specified program:

In a multithreaded environment, a program cannot execute a CANCEL statement naming a program that is active on any thread. The named program must be completely inactive.

Called subprograms can contain CANCEL statements. However, a called subprogram must not execute a CANCEL statement that directly or indirectly cancels the calling program itself or that cancels any program higher than itself in the calling hierarchy. In such a case, the run unit is terminated.

A program named in a CANCEL statement must be a program that has been called and has not yet executed an EXIT PROGRAM or a GOBACK statement.

A program can cancel a program that it did not call, provided that, in the calling hierarchy, the program that executes the CANCEL statement is higher than or equal to the program it is canceling. For example:

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.)

Terms of use | Feedback

Copyright IBM Corporation 1996, 2008.
This information center is powered by Eclipse technology. (http://www.eclipse.org)