sunnyk
New User
Joined: 20 Oct 2004 Posts: 59
|
|
|
|
Hi,
The CANCEL command is used when you are calling a subprogram dynamically.When u issue cancel command after a dynamic call to subprogram,it will refresh or reset all the parameters that got updated in subprogram.
The CANCEL statement ensures that the next time the referenced subprogram is called it will be entered in its initial state.
If using dynamic CALL, for the first CALL for a given module, that module is loaded into memory. CANCEL for that same program name will remove it from memory.
When a CANCEL statement is executed, all programs contained within the program referenced by the CANCEL statement are also canceled.
A program can, however, cancel a program that it did not call, providing that,
in the calling hierarchy, it 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.)
A CANCEL statement:
Closes all open files
Operates only on the program specified, and not on any program that may have been called by the canceled program.
No action is taken when you use a CANCEL statement to cancel the following types of programs:
A program that has not been called in the run unit
A program that has been called and subsequently canceled.
Regds
sunny |
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
As Sunnyk stated these things seem to happen and from one perspective it's not "wrong" to think that.
But what actually happens is that the current version of the CALLed pgm is CANCELed, that is, it's no longer active. The memory originally allocated to that version is freed and becomes available to the next requestor and the next CALL of that pgm is loaded from disk and must compete for task memory (which may or may not be available then).
Because of this load all Working storage appears to be reinitialized. In fact the pgm is reloaded with its original WS contents. |
|