ABAP Keyword Documentation → ABAP − Reference → Text Repositories → Messages → System Interfaces for Messages → System Interface IF_T100_DYN_MSG for Messages
IF_T100_DYN_MSG for Exception error_message
This example demonstrates how a caught message of a function module is forwarded.
Other versions: 
 7.31 | 7.40 | 7.54
Source Code
    TRY.
        CALL FUNCTION 'DEMO_FUNCTION_MESSAGE'
          EXPORTING
            message_type  = 'A'
            message_place = 'in Function Module'
            message_event = 'START-OF-SELECTION'
          EXCEPTIONS
            error_message = 4.
        IF sy-subrc <> 0.
          RAISE EXCEPTION TYPE cx_demo_dyn_t100
            MESSAGE ID sy-msgid
            TYPE sy-msgty
            NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
      CATCH cx_demo_dyn_t100 INTO DATA(oref).
        cl_demo_output=>display(
          |Caught exception:\n\n| &&
          |"{ oref->get_text( ) }", Type { oref->msgty } | ).
        MESSAGE oref TYPE 'I' DISPLAY LIKE oref->msgty.
    ENDTRY.
Description
This example works in basically the same way as the
executable example when transforming a
classic exception raised using MESSAGE RAISING to a class-based exception.
Here, however, a message of type A caught using error_message is transformed.
Note
See also the executable example for
using a short form of statement RAISE EXCEPTION MESSAGE.