Get Example source ABAP code based on a different SAP table
• ID MESSAGE • TYPE MESSAGE • NUMBER MESSAGE • TYPE MESSAGE oref
MESSAGE>, msg> Short Reference >
ABAP_SYNTAX ... ${ tn $}> $| ${ tn(id) $}> $| ${ ID mid TYPE mtype NUMBER num $}> BEGIN_SECTION VERSION 5 OUT $| ${ oref $[TYPE mtype$] $}> END_SECTION VERSION 5 OUT ...>
ABAP_ALTERNATIVES: 1 ... tn ...> 2 ... tn(id) ...> 3 ... ID mid TYPE mtype NUMBER num ...> BEGIN_SECTION VERSION 5 OUT 4 ... oref $[TYPE mtype$] ...> END_SECTION VERSION 5 OUT
What does it do? msg> specifies a message> from the database table T100>> either by specifying the message key consisting of id> and n> directly or by using the content of the data objects mid> and num> for the message class and the message number. Alternatively, an object reference variable oref> is specified whose dynamic type> implements the interface IF_T100_MESSAGE> >. The message type> that controls the behavior> of the message must be specified directly in t> or as content of the data object mtype>. The following message types are possible: A>, E >, I>, S>, W>, or X>. An invalid type produces a syntax error or runtime error. If the specified message is not found for the logon language> of the current user, a search is made in the secondary language> in AS ABAP and then in English. If it is still not found, the specified message type, message class, and message number are used as short text in uppercase letters and separated by a colon :>. The system fields of the statement MESSAGE> are always supplied with the specified values.
Latest notes: NON_V5_HINTS
The maximum length of a message is 269 and is determined from the short text of the message in the database table T100>> with a maximum of 73 characters) including up to four single-character placeholders >. These placeholders can be replaced by strings with a maximum of 50 characters using the addition WITH>>.
The extended program check> checks the existence of statically specified messages. ABAP_HINT_END
ABAP Alternative 1 ... tn ...>
What does it do? t> and n> are used to specify the single-character message type and the three-digit message number directly one after another (static short form). The message class must be specified with the addition MESSAGE-ID> in the statement that introduces the program.
ABAP_EXAMPLE_VX5 Display of the short text of the message with the number 014 from the message class SABAPDOCU> as an information message>. ABEXA 00407 ABAP_EXAMPLE_END
ABAP Alternative 2 ... tn(id) ...>
What does it do? The same applies to t> and n> as to the static short form. In the static long form, the message class is specified directly in parentheses using id>.
Latest notes: Specifying the message class explicitly overrides the addition MESSAGE-ID> of the statement that introduces the program. Specifying the message class in parentheses does not mean here that the content of id> is used. Instead, the message class is used that has the name that was specified directly with id>. NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_VX As in the example for alternative 1, with the message class specified explicitly. ABEXA 00408 ABAP_EXAMPLE_END
ABAP_EXAMPLE_V5 As in the example for alternative 1, with the message class specified explicitly. ABEXA 01685 ABAP_EXAMPLE_END
ABAP Alternative 3 ... ID mid TYPE mtype NUMBER num ...>
What does it do? The message class, the message type, and the message number are specified as content of the data objects mid>, mtype>, and num> (dynamic form). mid> and mtype> expect character-like data objects that must contain the message class or the message type in uppercase letters. Invalid message types raise an uncatchable exception. num> expects a data object of the type n> and length 3.
Latest notes: Specifying the message class explicitly overrides the addition MESSAGE-ID> of the statement that introduces the program. NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_VX As in the example for alternative 2, with the message and the message type specified dynamically. ABEXA 00409 ABAP_EXAMPLE_END
ABAP_EXAMPLE_V5 As in the example for alternative 2, with the message and the message type specified dynamically. ABEXA 01686 ABAP_EXAMPLE_END
ABAP Alternative 4 ... oref $[TYPE mtype$] ...> BEGIN_SECTION ID MESSAGE-oref
What does it do? For oref>, an object reference variable can be specified which, when the statement MESSAGE> is executed, points to an object whose class implements the system interface IF_T100_MESSAGE>>. This in turn contains the component interface> IF_MESSAGE>>. oref> is a functional operand position>. If oref> is specified, the addition WITH>> and the variant with INTO>> are not allowed. The statement MESSAGE> evaluates the components of the structured attribute T100KEY> of the interface IF_T100_MESSAGE>> in the referenced object:
The message class is taken from the component MSGID> and the message number from the component MSGNO>. If the message is not found, a short text is generated that lists the message class and message number used plus the placeholder texts.
The names of attributes of the object are taken from the components ATTR1> to ATTR4>. The placeholders 1> to 4> and > of the short text or <(> <)>V1 > to <(> <)>V4 > of the message long text are replaced with the content of these attributes in accordance with rules of the addition WITH>>. If an attribute does not exist or an attribute cannot be converted to a placeholder text, the character > is added to the start and the end of the attribute name and used as a placeholder text. Initial components ATTR1> to ATTR4> produce initial placeholder texts. The message type is either specified explicitly or determined implicitly.
The type is specified explicitly using TYPE mtype>, where mtype> expects a character-like data object containing a valid message type in uppercase letters.
If oref> points to an object that implements the system interface IF_T100_DYN_MSG>> and this is known statically, the addition TYPE> can be omitted and the message type in MSGTY> is used.
Latest notes:
If field symbols or formal parameters of the generic type any> or data> are specified for oref>, the variant MESSAGE text>> is used, which has identical syntax.
This variant is mainly intended to be used with exception objects>. If a global exception class> implements the interface IF_T100_MESSAGE>, the components of the structure T100KEY> are filled in accordance with the definition of the associated exception text when a corresponding exception is raised in the interface method GET_TEXT>, which is itself implemented in the superclass CX_ROOT>. In local exception classes, the components must be filled manually. To do this, the interface method GET_TEXT > should not be redefined and the instance constructor should be used instead.
The system interface IF_T100_DYN_MSG>> includes IF_T100_MESSAGE> and objects from classes that implement IF_T100_DYN_MSG> can be used accordingly. IF_T100_MESSAGE> is intended to be used on its own for statically predefined exception texts> of exception classes and IF_T100_DYN_MSG> enables exception objects to be linked with messages>.
If the TYPE> addition is omitted for an object with the system interface IF_T100_DYN_MSG>>, the addition TYPE oref->if_t100_dyn_msg~msgty> is added implicitly.
For compatibility reasons, this variant can still be used for classes that only implement the interface IF_MESSAGE>. In this case, the interface methods GET_TEXT> and GET_LONGTEXT> are called automatically in the referenced object and their return value is used as the short text or long text of the message. In this case, the system fields sy-msgid> and sy-msgno> are not filled specifically. The root class of all exception classes > CX_ROOT> implements the interface IF_MESSAGE>. In exception classes that do not implement the interface IF_T100_MESSAGE>, the interface methods GET_TEXT> and GET_LONGTEXT> get the exception texts of exception objects stored in OTR (Online Text Repository ), which then can be displayed as a message using the variant of the MESSAGE> statement. NON_V5_HINTS ABAP_HINT_END
Example ABAP Coding
Sending of a messages using an object of the class cls> created using the instance operator NEW >> that implements the system interface IF_T100_DYN_MSG>>. The message is specified completely by interface attributes of the object. ABEXA 00410 ABAP_EXAMPLE_END
ABAP_EXAMPLES_ABEXA
System Interface IF_T100_MESSAGE> in a Regular Class>
System Interface IF_T100_MESSAGE> in a Local Exception Class>
System Interface IF_T100_MESSAGE> in a Global Exception Class> ABAP_EXAMPLE_END END_SECTION ID MESSAGE-oref