What is the difference between CANCEL and INITIAL statement

This is a Mainframe COBOL forum - you can post your queries on Mainframe COBOL, VS COBOL II, COBOL/370 , Enterprise COBOL

Moderators: dbzTHEdinosauer, Moderator Group

Post Reply
vjrithwik
Member
Posts: 2
Joined: Thu Oct 12, 2006 11:29 am

What is the difference between CANCEL and INITIAL statement

Post by vjrithwik » Thu Oct 12, 2006 12:25 pm

Hi,

What is difference between CANCEL and INITIAL statements.
Regards,
Rithwik

"To learn to read is to light a fire; every syllable that is spelled out is a spark?

User avatar
Krishna
Site Admin
Posts: 1052
Joined: Fri Jan 27, 2006 7:50 am

Post by Krishna » Thu Oct 12, 2006 5:22 pm

Hi Rithwik,

CANCEL is used to initialize the sub-program. INITIAL is used to initialise the same program.
More information.........

CANCEL statement.
-----------------------

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

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



NOTE : No action is taken when a CANCEL statement is executed, if subprogram has not been dynamically called.



INITIAL Statement
-----------------------

Specifies that when program-name is called, program-name and any programs contained
within it are placed in their initial state. The INITIAL attribute is not supported for programs
compiled with the THREAD option.

INITIAL statement is used with PROGRAM-ID statement.




Thanks,
Krishna

gmt360
Member
Posts: 1
Joined: Mon May 31, 2010 2:06 pm

Post by gmt360 » Tue Jun 01, 2010 1:21 pm

Sorry for replying to an older post.
If not valid pls let me know, however it is related.

Do we use IS INITIAL in sub-program only?

Dynamically called programs are always in Initial Mode, Is it automatic or do we need to Code IS INITIAL or CANCEL?/

Pls reply

thanks

Garry

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Tue Jun 01, 2010 11:36 pm

Dynamically called programs are always in Initial Mode
not true

only for first CALL. after that, without a CANCEL, next time pgm is CALLed, it is in last left status.
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Tue Jun 01, 2010 11:37 pm

Dynamically called programs are always in Initial Mode
not true

only for first CALL. after that, without a CANCEL, next time pgm is CALLed, it is in last left status.

only with the program-id clause INITIAL,
will a program (dynamically or statically) be load on each CALL in initial state.
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

academyindia4

Topic deleted by Admin

Post by academyindia4 » Wed Jan 27, 2016 8:32 pm

<< Content deleted By Admin >>

academyindia4

Topic deleted by Admin

Post by academyindia4 » Sat Jan 30, 2016 11:42 pm

<< Content deleted By Admin >>

academyindia4

Topic deleted by Admin

Post by academyindia4 » Mon Feb 01, 2016 10:10 pm

<< Content deleted By Admin >>

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others