Requirements for a method procedure division
There are specific requirements when you code a method procedure division.
The requirements are:
- You can use the EXIT METHOD statement
or the GOBACK statement to return control to
the invoking method or program. An implicit EXIT METHOD statement
is generated as the
last statement of every method procedure division.
For details on the EXIT METHOD statement, see Format 3 (method).
- You can use the STOP RUN statement (which terminates the run unit) in a method.
- You can use the RETURN-CODE special register within a method procedure division to access return codes from subprograms that are called with the CALL statement, but the RETURN-CODE value is not returned to the invoker of the current method. Use the procedure division RETURNING data name to return a value to the invoker of the current method. For details, see the discussion of RETURNING data-name-2 under The PROCEDURE DIVISION header.
You cannot specify the following statements or clauses in a method procedure division:
- EXIT PROGRAM
- GO TO without a specified procedure name
- USE FOR DEBUGGING