How to Stop Run in COBOL

Knowing how to stop a computer program is just as important as knowing how to start one. In this specific case, COBOL is no different. Getting your COBOL program to cease operation under a controlled condition is compulsory to its successful task. Of course, there are a number of ways to do this, and the important aspect is not only knowing these options but also knowing when to invoke them. There may be instances where you want your COBOL program to halt execution and relinquish control to another module, or perhaps you may want to stop it unconditionally.

Instructions

    • 1

      Go to the "Procedure Division" in your COBOL program, and determine where in the logic you want to end processing. If another module is calling your program in the system, and that calling module is expecting control to be returned to it, enter the command "GOBACK." This will gracefully terminate your program and pass control back to the invoking point of the module.

    • 2

      Enter the command "Exit Program" at the same point in the "Procedure Division" where you wish your COBOL program to stop. Make sure that the module you are issuing this command from is a sub-program passing control back to the calling module. If this is the main module and you have coded the "Exit Program" statement, it will abnormally end (ABEND) at the compile stage with an error code like "Abend4038." It is essential that this module is not the main program when issuing the "Exit Program" directive.

    • 3

      Enter the "STOP RUN" command to terminate all processing of your COBOL module. Control will pass back to the operating system even if it is being issued from a sub-module or sub-program.

Related Searches:

References

Resources

Comments

Related Ads

Featured