STOP Statement
The STOP
statement terminates the current program.
Format 1
STOP RUN [ {RETURNING} numeric-1 ]
{GIVING }
Syntax:
numeric-n
is a literal or data item that is numeric.
General Rules:
- A Format 1
STOP RUN
statement terminates the program, optionally returning a return code to the operating system. AnyOPEN
files areCLOSE
'd. - In the Format 1
STOP RUN
statement, theRETURNING
/GIVING
clause returns the value ofnumeric-1
to the operating system through the special return-code register. RETURNING
andGIVING
are synonyms.
Code Sample:
IDENTIFICATION DIVISION.
PROGRAM-ID. STOP-1.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
77 NUMERIC-1 PIC 9 VALUE 1.
77 DUMMY PIC X.
PROCEDURE DIVISION.
MAIN.
*FORMAT 1
*STOP RUN [ {RETURNING} NUMERIC ]
* {GIVING }
EVALUATE DUMMY
WHEN "A"
STOP RUN
WHEN "B"
STOP RUN RETURNING NUMERIC-1
WHEN "C"
STOP RUN GIVING NUMERIC-1
WHEN "D"
STOP RUN RETURNING 1
WHEN "E"
STOP RUN GIVING 1
WHEN OTHER
CONTINUE
END-EVALUATE.
DISPLAY "STOP-1 FINISHED!" LINE 15 COL 10.
ACCEPT DUMMY LINE 15 COL 30.
STOP RUN.