SAP NetWeaver AS ABAP Release 740, ©Copyright 2014 SAP AG. All rights reserved.
ABAP Keyword Documentation → ABAP − Reference → Program Flow Logic → Exception Handling → Exceptions Before Class-Based Exceptions → Non-Class-Based Exceptions →
MESSAGE - RAISING
Syntax
MESSAGE { msg |
text } RAISING exception [WITH dobj1 ... dobj4].
Effect
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.
The system fields of the statement MESSAGE are populated in both cases and are available in the calling program after handling an exception raised with MESSAGE ...RAISING. This is especially true if a function module was called through Remote Function Call (RFC).
Notes
Example
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.