Created on May 12, 2021, 4:31 p.m. - by John, Prince
Please explain the difference between STOP RUN and GOBACK
Check the below link. hope you to get an answer for your question
STOP RUN - https://www.ibmmainframer.com/cobol-tutorial/cobol-stop-run-statement/
GOBACK - https://www.ibmmainframer.com/cobol-tutorial/cobol-goback-statement/
Main Program: Return to calling program. (Might be the operating system, and job will end.) STOP RUN terminates the run unit, and deletes all dynamically called programs in the run unit and all programs link-edited with them. (It does not delete the main program.) In a threaded environment the entire Language Environment enclave is terminated, including all threads executing within the enclave.
Sub Program: Return directly to the program that called the main program. (Might be the operating system, and job will end.) In a threaded environment, the entire Language Environment enclave is terminated, including all threads executing within the enclave.
Main Program: Same effect as STOP RUN: return to calling program. (Might be the operating system, and job will end.) In a threaded environment, the thread is terminated.
Sub Program: Return to calling program. In a threaded environment, if the program is the first program in a thread, the thread is terminated.
If the main program is called by a program written in another language that does not follow Language Environment linkage conventions, return is to this calling program. If the thread is the initial thread of execution in an enclave, the enclave is terminated.
I suggested you to use GOBACK instead of STOP RUN
The stop run statement does exactly what you might think it does. It stops the run of the program.
This is the last statement the program executes when a program completes successfully.
It isn't necessarily the last statement in the program, it's simply the last one executed by the program.
The execution of this statement returns control back to the system.
The goback statement is similar to the stop run statement in that it ends the execution of the current program.
However, instead of always returning control back to the system, it returns control back to whoever called it.
For most batch programs, the calling program. In those cases, goback and stop run perform the same function.
However, if you're in a subprogram, if this program was called by some other program. Then the goback returns to the calling program. Under that same scenario, a stop run statement would still return control back to the system. Ending not only this program but the one being called.
So, in the end, unless you have a really, really good reason you need to use stop run to end your program. From my experience, I highly recommend using goback.
This is my first post in #ibmmainframer. Happy that I got many responses. Thank you ALL