Get Example source ABAP code based on a different SAP table
• RAISING MESSAGE ID MESSAGE-RAISING
MESSAGE>, RAISING> Short Reference >
ABAP_SYNTAX MESSAGE ${ msg> $| text > $} $[DISPLAY LIKE dtype$]> $[WITH dobj1... dobj4$]> RAISING exception.>
What does it do? The statement MESSAGE>> with the addition RAISING> raises a non-class-based exception exception> and only sends a message if the exception is not handled. The semantics of msg>>, text>> , and WITH>> is the same as in the statement MESSAGE> without the addition RAISING>. This addition only makes sense during the processing of methods and function modules in which the non-class-based exception exception> is defined. Furthermore, it cannot be used in the same processing block> as the statement RAISE EXCEPTION> or the addition THROW>> in a conditional expression> to raise class-based exceptions.
If the MESSAGE> statement is executed with the addition RAISING> during processing of a method or a function module whose caller assigns a return value to the exception> exception> using the addition EXCEPTIONS> of the statement CALL>, the statement has the same effect as the statement RAISE>>.
If no return code is assigned to the exception exception>, the addition RAISING> is ignored, and the message is sent using the statement MESSAGE>> and processed> according to its message type>. The system fields of the statement MESSAGE> are filled in both cases and are available in the calling program after an exception raised using MESSAGE ...RAISING> is handled. BEGIN_SECTION VERSION 5 OUT This applies in particular if a function module was called using Remote Function Call (RFC>). END_SECTION VERSION 5 OUT
Latest notes:
The statement MESSAGE ... RAISING> is to be seen primarily as a statement for raising exceptions and not for sending messages. Such an exception should always be handled like an exception raised using RAISE>, since the behavior of the message depends strongly on the context and cannot usually be predicted when the function module is created.
Using MESSAGE ... RAISING> in cases in which non class-based exceptions must still be used is preferable to using the RAISE> statement, because it offers the option of providing additional text information with an exception.
A return code can be assigned to messages that are sent in function modules without the addition RAISING> by using the predefined exception error_message>>.
Messages that are sent as messages when a function module is called and that are not caught despite the addition RAISING> are affected like messages with error_message> >.
If a procedure> is exited by raising an exception, the content of the formal parameter for which the pass by value> is defined is not assigned to the respective actual parameters. NON_V5_HINTS ABAP_HINT_END
Example ABAP Coding
When the message is called for the first time, an information message> is sent. The second time, an exception is raised instead, which is handled by sy-subrc>. CLASS c1 DEFINITION. PUBLIC SECTION. CLASS-METHODS m1 EXCEPTIONS exc1. ENDCLASS. CLASS c1 IMPLEMENTATION. METHOD m1. MESSAGE 'Message in a Method' TYPE 'I' RAISING exc1. ENDMETHOD. ENDCLASS. ... c1=>m1( ). c1=>m1( EXCEPTIONS exc1 = 4 ). IF sy-subrc = 4. ... ENDIF.> ABAP_EXAMPLE_END