In the source code editor of an ABAP exception class, you can add the code template textIdExceptionClass. This code template contains the constant definitions for assigning the message number and attributes of a message class that are to be displayed.
<example>The code template is added:<codeblock><codeph>CONSTANTS: BEGIN OF [Name of the exception class], msgid TYPE symsgid VALUE 'msgid', msgno TYPE symsgno VALUE 'msgno', attr1 TYPE scx_attrname VALUE 'attr1', attr2 TYPE scx_attrname VALUE 'attr2', attr3 TYPE scx_attrname VALUE 'attr3', attr4 TYPE scx_attrname VALUE 'attr4', END OF [Name of the exception class]. </codeph> </codeblock></example>
EXAMPLE
In the following example, you see the code snippet of an ABAP exception class referring to a message in the message class BC_DATAMODEL_SERVICE.
There is the exception class CX_MY_EXCEPTION_CLASS:
As a result, the exception message is displayed as 'Number of booked places 242 exceeds flight capacity 200'.
CONSTANTS: BEGIN OF CX_MY_EXCEPTION_CLASS, msgid TYPE symsgid VALUE 'BC_DATAMODEL_SERVICE', msgno TYPE symsgno VALUE '118', attr1 TYPE scx_attrname VALUE 'BOOKED_SEATS', attr2 TYPE scx_attrname VALUE 'SEATS', attr3 TYPE scx_attrname VALUE '', attr4 TYPE scx_attrname VALUE '', END OF CX_MY_EXCEPTION_CLASS. DATA seats TYPE i READ-ONLY. DATA booked_seats TYPE i READ-ONLY.