I am using a subroutine (FORM
, ENDFORM
) where there is a class-method calling that raises an exception. I am catching the exception from the class-method calling, but how can I pass this exception to where I call the subroutine (PERFORM
)?
CodePudding user response:
There's a documentation section for Class-Based Exceptions in Procedures .
If a class-based exception is not handled in a procedure, the system attempts to propagate it to the caller of the procedure. The exceptions that can be propagated from a procedure must be declared in its interface. The caller then knows which exceptions to expect from the procedure. Class-based exceptions are divided into three categories, which determine whether the declaration must be explicit and how it is checked.
In methods of local classes and subroutines, the addition RAISING of the statements METHODS and FORM is used for the declaration
Undeclared exceptions cannot leave a procedure and violate the interface if they are not handled within the procedure. A violation of the interface raises an exception of the predefined class CX_SY_NO_HANDLER, whose exception object contains a reference to the original exception in the attribute PREVIOUS.
See also documentation for FORM RAISING.
START-OF-SELECTION.
TRY.
PERFORM test.
CATCH lcx_some_exception INTO DATA(lx_ex).
ENDTRY.
FORM test RAISING lcx_some_exception.
DATA(lo_test) = NEW lcl_test( ).
lo_test->test( ).
ENDFORM.