Stop Run in both called and calling programs.
Stop Run in both called and calling programs.
Hi,
What happens if we use STOP RUN in both called and calling program?
To get an answer about this I read that, if you give STOP RUN in the Called program, the control won't be returned to the calling program after executing the called program. So, one need to use GO BACK always in the called program to transfer the control back to it's Calling program. However, Stop Run or Go Back both work fine in the main program. My question why is it so, what happens when we issue the STOP RUN and why it does not halt the excution of main program?
Thanks.
What happens if we use STOP RUN in both called and calling program?
To get an answer about this I read that, if you give STOP RUN in the Called program, the control won't be returned to the calling program after executing the called program. So, one need to use GO BACK always in the called program to transfer the control back to it's Calling program. However, Stop Run or Go Back both work fine in the main program. My question why is it so, what happens when we issue the STOP RUN and why it does not halt the excution of main program?
Thanks.
-
- Global Moderator
- Posts: 490
- Joined: Sun Aug 25, 2013 7:24 pm
Re: Stop Run in both called and calling programs.
STOP RUN causes return to the Operating System. GOBACK causes return to the program which called it. In the case of the program which is the entry-point used to satisfy EXEC PGM=... in the JCL, the Operating System has "called" the program, so STOP RUN and GOBACK give the same results.
It is much more flexible to use GOBACK. The allows you to have a program which CALLs your "main program" and which can, for instance, interrogate the RETURN-CODE from your "main program". With STOP RUN, this would not be possible.
It is much more flexible to use GOBACK. The allows you to have a program which CALLs your "main program" and which can, for instance, interrogate the RETURN-CODE from your "main program". With STOP RUN, this would not be possible.
Re: Stop Run in both called and calling programs.
Thanks. I've got one more question:
This is reason when we talk about IMS or CICS then we always use GOBACK and the COBOL program works as a "sub-program" which sends the return back to the IMS or CICS?
But then how IMS and CICS behave as we've not coded anything to make them work with zOS?
This is reason when we talk about IMS or CICS then we always use GOBACK and the COBOL program works as a "sub-program" which sends the return back to the IMS or CICS?
But then how IMS and CICS behave as we've not coded anything to make them work with zOS?
- Robert Sample
- Global Moderator
- Posts: 1903
- Joined: Fri Jun 28, 2013 1:22 am
- Location: Dubuque Iowa
Re: Stop Run in both called and calling programs.
The Enterprise COBOL Language Reference manual has a table to define what happens with a STOP RUN:When STOP RUN is used in IMS or CICS, the "system" is IMS or CICS -- not the operating system. Note the wording the manual uses -- STOP RUN in a subprogram returns to the "program that called the main program" .
Code: Select all
_________ _________________________________ _____________________________
| Terminat|on | |
| statemen| Main program | Subprogram |
|_________|_________________________________|_____________________________|
| STOP | Returns to the calling program. | Returns directly to the |
| RUN | (Can be the system, which | program that called the |
| | causes the application to end.) | main program. (Can be the |
| | | system, which causes the |
| | | application to end.) |
|_________|_________________________________|_____________________________|
-
- Global Moderator
- Posts: 490
- Joined: Sun Aug 25, 2013 7:24 pm
Re: Stop Run in both called and calling programs.
Code STOP RUN in a CICS or IMS program at your peril, however. I was told never to do that, so I've never tried it. I assume there are consequences :-)
- Robert Sample
- Global Moderator
- Posts: 1903
- Joined: Fri Jun 28, 2013 1:22 am
- Location: Dubuque Iowa
Re: Stop Run in both called and calling programs.
Merely coding STOP RUN in a CICS program is no big deal (and actually COBOL requires a program termination statement -- EXIT PROGRAM, GOBACK, STOP RUN -- be present for the program to be syntactically correct).
However, if CICS actually executes that STOP RUN statement .... well, CICS was invoked from the operating system (and hence functions as a main program), and your transaction runs under CICS (hence your program functions as a subprogram) with predictable consequences as the manual I quoted indicates. The CICS region comes down. I assume IMS would function the same way, but don't have any experience with it to say for sure.
However, if CICS actually executes that STOP RUN statement .... well, CICS was invoked from the operating system (and hence functions as a main program), and your transaction runs under CICS (hence your program functions as a subprogram) with predictable consequences as the manual I quoted indicates. The CICS region comes down. I assume IMS would function the same way, but don't have any experience with it to say for sure.
Re: Stop Run in both called and calling programs.
What will happen if it actually gets executed?? And, for that matter, what condition can be that where the STOP RUN never gets executed, I wonder? Can you please elaborate on it.Robert Sample wrote:Merely coding STOP RUN in a CICS program is no big deal (and actually COBOL requires a program termination statement -- EXIT PROGRAM, GOBACK, STOP RUN -- be present for the program to be syntactically correct).
- Robert Sample
- Global Moderator
- Posts: 1903
- Joined: Fri Jun 28, 2013 1:22 am
- Location: Dubuque Iowa
Re: Stop Run in both called and calling programs.
My post explicitly stated what happens if the STOP RUN gets executed -- the CICS region comes down. Typical coding would be so the STOP RUN cannot be executed.
Code: Select all
EXEC CICS RETURN END-EXEC.
STOP RUN.
Create an account or sign in to join the discussion
You need to be a member in order to post a reply
Create an account
Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute