There is a discussion in many forums that if we give ‘STOP RUN’ in the COBOL sub-module what will happen.
The definition from IBM – A STOP RUN statement returns control to the caller of the program at the nearest control boundary. If this is a hard control boundary, the activation group (run unit) will end, and all files scoped to the activation group will be closed.
The answer to this question is as follows.
This is a Tricky question for COBOL developers. The right answer is it will stop executing the program.
Sub-program cannot send control back to the main module. So your execution will be stopped when you give STOP RUN.
Whereas the GOBACK and EXIT-PROGRAM are only passed control back to the calling program.
GOBACK has dual capability it can be given in both main and sub modules.