SAP MESSAGE EXCEPTIONS



Get Example source ABAP code based on a different SAP table
  



Exception Classes for Messages
The exception texts described in the previous section are assigned to an exception class statically and express a predefined semantic meaning. This applies to both categories of exception texts, namely messages as exception texts and internal exception texts from OTR.
Another frequent use case is passing a message from the table T100 to the exception object when an exception is raised. This is the case, for example, when a non-class-based exception raised using MESSAGE RAISING is handled or a message of a function module is caught using error_message and then passed as a class-based exception.
The predefined exception texts that are selected using the input parameter TEXTID of the instance constructor are not suitable for this purpose. Instead, the following are available:
The system interface IF_T100_DYN_MSG.
The addition MESSAGE of the statement RAISE EXCEPTION and of the addition THROW in a conditional expression.
Exception objects of exception classes that include the system interface IF_T100_DYN_MSG can be linked with any message from the table T100 using the addition MESSAGE . Exception objects of exception classes that include only the system interface IF_T100_MESSAGE can also be linked with messages using the addition MESSAGE with restrictions. The latter option is intended only for exception classes that previously had no specific exception texts for generic use before IF_T100_DYN_MSG was introduced. In other cases, the concept of exception texts and the linking of any messages are strictly separated with special exception classes provided specifically for this purpose. In particular, the addition MESSAGE cannot be combined with the input parameter TEXTID.
BEGIN_SECTION VERSION 5 OUT

ABAP_EXAMPLES_ABEXA
System Interface IF_T100_DYN_MSG in a Local Exception Class
System Interface IF_T100_DYN_MSG in a Global Exception Class
System Interface IF_T100_DYN_MSG for Exception error_message
System Interface IF_T100_MESSAGE for Exception with Message
ABAP_EXAMPLE_END
END_SECTION VERSION 5 OUT