Google Search - Blog...........

ABAP - OOPS : Demo On Locally Defined Exception - Class.

REPORT YSUBCLASS_EXCEPTION_3.

CLASS cx_my_exception DEFINITION
INHERITING FROM CX_STATIC_CHECK.
ENDCLASS.

CLASS cx_my_exception IMPLEMENTATION.
ENDCLASS.

CLASS C1 DEFINITION.
PUBLIC SECTION.
METHODS: m1 raising cx_my_exception .
ENDCLASS.

CLASS c1 IMPLEMENTATION.
METHOD m1.
RAISE EXCEPTION TYPE cx_my_exception.
ENDMETHOD.
ENDCLASS.

DATA: ex TYPE REF TO cx_my_exception,
oref TYPE REF TO c1.

START-OF-SELECTION.
TRY.
CREATE OBJECT oref.
oref->m1( ).
CATCH cx_my_exception INTO ex.
write:/5 'My Exception caught'.

ENDTRY.


Output My exception caught

No comments:

Post a Comment