STOP RUN
The COBOL statement that ends the whole run, including every program that called this one.
Also written EXIT PROGRAM, RETURN-CODE special register, ending a COBOL program
STOP RUN ends the run unit: the main program and every program it called, all at once. Control goes back to the operating system, and the job step ends.
That is different from GOBACK. In a main program, GOBACK also ends the run. In a subprogram, GOBACK returns to the program that called it, which is usually what you want. EXIT PROGRAM does the same as GOBACK in a subprogram. A subprogram that uses STOP RUN by mistake ends the whole job step from inside a routine, which is a classic bug. Many sites therefore use GOBACK everywhere.
Before ending, a program can set the step's return code by moving a value to the RETURN-CODE special register: MOVE 8 TO RETURN-CODE. The job then sees that value, and later steps can test it with COND or IF.
STOP RUN is not used in CICS programs. A CICS program ends with EXEC CICS RETURN, which hands control back to CICS.
Where can I learn this hands-on?
Right here, at ZedBank. You take a junior job at a simulated bank and learn each part of the work by doing it, with Zed beside you. There's nothing to install.
Start at ZedBankRelated
- CALLThe COBOL statement that runs another program and passes data to it, then continues when that program returns.
- Return codeA number a program leaves behind saying how it went. Zero for clean, higher numbers for warnings and failures.
- PROCEDURE DIVISIONThe part of a COBOL program that contains the actual logic, the statements that run.
- COBOLThe programming language most business logic on the mainframe is written in. Verbose by design, and still running the world's payments.
- LINKAGE SECTIONThe part of a COBOL program's DATA DIVISION that describes data passed in from outside, such as from a calling program.