Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Program Flow Logic →  Exception Handling →  Class-Based Exceptions →  RAISE EXCEPTION →  RAISE EXCEPTION - message 

Converting the Exception error_message to a Class-Based Exception

The example demonstrates the short form of the statement RAISE EXCEPTION with the addition MESSAGE.

Other versions: 7.31 | 7.40 | 7.54

Source Code

            message_type  = 'A'
            message_place = 'in Function Module'
            message_event = 'START-OF-SELECTION'
            error_message = 4.
        IF sy-subrc <> 0.
          RAISE EXCEPTION TYPE cx_demo_dyn_t100 USING MESSAGE.
      CATCH cx_demo_dyn_t100 INTO DATA(oref).
          |Caught exception:\n\n| &&
          |"{ oref->get_text( ) }", Type { oref->msgty } | ).
        MESSAGE oref TYPE 'I' DISPLAY LIKE oref->msgty.


The example has exactly the same functionality as the executable example IF_T100_DYN_MSG for the exception error_message. Here, the addition USING MESSAGE is used, which explicitly passes the system fields sy-msgty, sy-msgid, sy-msgno, and sy-msgv1 to sy-msgv4 to the corresponding additions of the statement RAISE EXCEPTION.