Get Example source ABAP code based on a different SAP table
Exception Texts Each exception is assigned a text that can be parameterized by attributes and that describes the exception situation. This text is displayed in the short dump> of the runtime error if the exception is not handled. If the exception is handled in the program, the text can be read using the method GET_TEXT> of the interface IF_MESSAGE>, which is implemented by every exception class. Any long text can be read using the method GET_LONGTEXT>. A global exception class has a predefined exception text with the same name as the exception class. This predefined text can be edited and further exception texts can be defined. From a technical perspective, each exception text is defined by an identically named static constant in the public visibility section of the exception class that defines its properties. The instance constructor of an exception class has an input parameter TEXTID> to which such a constant can be passed when the exception is raised to determine the exception text. If the parameter is not passed, the predefined exception text with the same name as the exception class is used. The exception texts of an exception class are usually defined by referring to messages> in the table T100>>. In predefined system classes, OTR (Online Text Repository) texts can also be used.
Messages as Exception Texts>
Exception Texts for System Classes>
ABAP_PGL Using Messages as Exception Texts> ABAP_PGL_END
Latest notes:
The names of the exception texts or the associated constants should be understood as keys of the existing texts for an exception class. This means that when an exception is raised, only the constants of the exception class with the same name should be passed to the parameter TEXTID> to determine the exception text. NON_V5_HINTS
The maintenance of the exception texts, that is, the associated constants and the instance constructor, depends largely on whether the Class Builder> in the ABAP Workbench or the source code editor in the ABAP Development Tools (ADT)> is used. ABAP_HINT_END BEGIN_SECTION SAP_INTERNAL_HINT In the beginning, OTR texts were the preferred method and messages as exception texts were to be used in exceptional cases only. This has changed for two reasons:
OTR itself was not further developed and supported.
ADT does not support OTR texts as exception texts. Therefore, nowadays, messages are the preferred method for exception texts despite the fact that the handling is more complex than for OTR texts. END_SECTION SAP_INTERNAL_HINT