Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Program Flow Logic →  Exception Handling →  Exceptions Before Class-Based Exceptions →  Non-Class-Based Exceptions 


Quick Reference

Other versions: 7.31 | 7.40 | 7.54


MESSAGE { msg |
text } [DISPLAY LIKE dtype] [WITH dobj1... dobj4] 
        RAISING exception.


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, and the caller of the method or function module assigns a return code to the exception exception using the addition EXCEPTIONS of the statement CALL, the statement works in the same way 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 in accordance with 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. This is especially true if a function module was called using Remote Function Call (RFC).


  • The statement MESSAGE ... RAISING is primarily a statement for raising exceptions and not for sending messages. An exception of this type should always be handled like an exception raised using RAISE, since the behavior of the message depends strongly on the context and is usually unpredictable 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 sent as messages when a function module is called and not caught (despite RAISING) are processed as 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.


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.

       METHOD m1.
         MESSAGE 'Message in a Method' TYPE 'I' RAISING exc1.
       c1=>m1( ).
       c1=>m1( EXCEPTIONS exc1 = 4 ).
     IF sy-subrc = 4.