STOP Statement
The STOP statement halts execution of the object program either permanently or temporarily.
STOP Statement - Format >>-STOP--+-RUN-----+------------------------------------------->< '-literal-'
- literal
- May be numeric, nonnumeric or Boolean,
and may be any figurative constant except ALL literal. If the literal
is numeric, it must be an unsigned integer. IBM Extension
IBM Extension Cannot be a floating-point literal. End of IBM Extension
End of IBM Extension
When STOP literal is specified, the literal is communicated to the system operator for batch jobs and to the work station for interactive jobs. Program execution is suspended. Execution is resumed only after operator intervention.
- Operator
- Response Action
- G (default)
- Continue at next instruction.
- C
- Terminate the execution of all programs up to and including the program at the nearest control boundary. If the nearest control boundary is a hard control boundary then escape message CEE9901 is issued to the caller of the COBOL run unit. For batch jobs, the job is canceled if the ENDSEV parameter (see CRTJOBD CL command) for the job contains a value that is less than or equal to the severity of the message.
- D
- Dump COBOL identifiers and then perform the same action as C.
- F
- Dump COBOL identifiers and file information and then perform the same action as C.
The output of the STOP literal contains the program-name. The literal is contained in the second level text, and is displayed when the Help key is used.
The STOP literal statement is useful for special situations (a special tape or disk must be mounted, a specific daily code must be entered, and so forth) when operator intervention is needed during program execution. However, the ACCEPT and DISPLAY statements are preferred when operator intervention is needed.
When STOP RUN is specified, execution of all programs up to and including the program at the nearest control boundary is ended, and control is returned to the program prior to the control boundary. If the nearest control boundary is a hard control boundary, then STOP RUN causes the activation group (run unit) to end, which in turn causes all files scoped to the activation group to be closed. If a STOP RUN statement appears in a sequence of imperative statements, it must be the last or only statement in the sequence.
In each case above, the calling program could be the system. If it is, execution of the run unit ceases, and control transfers to the operating system.
Also, if the main program is called by a program written in a language that does not follow COBOL linkage conventions, return will be to this calling program.
For details on the behavior of the STOP RUN statement under various conditions, see "Returning from an ILE COBOL Program" in IBM® Rational® Development Studio for i: ILE COBOL Programmer's Guide.
