ABAPMESSAGE_MSG - MESSAGE MSG
ABAP Short Reference SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3upThis documentation is copyright by SAP AG.
MESSAGE - msg
Syntax
... { tn }
| { tn(id) }
| { ID mid TYPE mtype NUMBER num }
| { oref TYPE mtype } ... .
Alternatives:
1. ... tn ...
2. ... tn(id) ...
3. ... ID mid TYPE mtype NUMBER num ...
4. ... oref TYPE mtype ...
Effect
msg specifies a message from the database tableT100either by specifying id and n directly or by using the content of the data objects midand num for the message class and the message number. Alternatively, an object reference variable oref is specified whosedynamictype implements the interface IF_T100_MESSAGE. One of the possible message types "A", "E", "I","S", "W", or "X" must be specified, either by specifying t directly or as content of the data object mtype. This controls thebehavior of the message.
If the specified message is not found for the logon language of the current user, a search is made in the secondary language (profile parameterzcsa/second_language) and then in English. Ifit 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.
Alternative 1
... tn ...
Effect
t and n are used to specify the single-character message type and the three-digit messagenumber directly in a row (static short form). The message class must be specified with the addition MESSAGE-ID in the statement that introduces the program.
Example
Displays the short text of the message with the number 014 from the message class SABAPDOCU as aninformation message.
REPORT rep MESSAGE-ID sabapdemos.
...
MESSAGE i014.
Alternative 2
... tn(id) ...
Effect
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.
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 signify here that the content of id is used. In fact, the message class is used that has the name that was specified directly with id.
Example
As in the example for alternative 1, with the message class specified explicity.
REPORT ...
...
MESSAGE i014(sabapdemos).
Alternative 3
... ID mid TYPE mtype NUMBER num ...
Effect
The message class, the message type, and the message number are specified as content of the data objectsmid, mtype, and num (dynamic form). mid and mtype expect character-likedata objects that must contain the message class or the message type in uppercase letters. Invalid message types generate a non-handleable exception. num expects a data object of the type n and length 3.
Note
Specifying the message class explicitly overrides the addition MESSAGE-ID of the statement that introduces the program.
Example
As in the example for alternative 2, with the message and the message type specified dynamically.
DATA: mid TYPE sy-msgid VALUE 'SABAPDEMOS',
mtype TYPE sy-msgty VALUE 'I',
num TYPE sy-msgno VALUE '014'.
MESSAGE ID mid TYPE mtype NUMBER num.
Alternative 4
... oref TYPE mtype ...
Effect
For oref, you can specify an object reference variable which, when the statement MESSAGE is executed, points to an object whose class implements the system interface IF_T100_MESSAGE, which in turn contains thecomponentinterface IF_MESSAGE. mtype expects a character-like data object is expected that must contain the message type in uppercase letters.
The statement MESSAGE analyzes the components of the structured attribute T100KEY of the interfaceIF_T100_MESSAGE in the referenced object. Themessage class is taken from the component MSGID and the message number from the component MSGNO. Ifthe components ATTR1 through ATTR4 contain the names of other attributes of the object, the placeholders"&1" through "&4" and "&" of the short text or "&V1&" through "&V4&" of the long text of the messageare replaced by the content of these attributes according to the rules of usage given by the additionsWITH in message_options.If one of these components does not contain an attribute name, the character "&" is added to the content at the beginning and end, thus replacing the placeholder.
Notes
- In this variant, the additions WITH and INTO in message_options are not allowed.
- If field symbols or formal parameters of the generic type any or data are specified fororef, then the syntactically identical variant MESSAGE text is used.
- This variant is mainly intended to be used with exception objects. If a globalexceptionclass implements the interface IF_T100_MESSAGE, then the components of the structure T100KEY arefilled in accordance with the definition of the associated exception text when such an exception israised in the interface method GET_TEXT (which is implemented in the superclass CX_ROOT). In local exceptionclasses, you must fill the components yourself. To do this, do not redefine the interface method GET_TEXT, but use the instance contructor instead.
- For compatibility reasons, this variant can still be used for classes that only implement the interfaceIF_MESSAGE. In this case, the interface methods GET_TEXT and GET_LONGTEXT are called automatically inthe 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 allexceptionclasses, CX_ROOT, implements the interface IF_MESSAGE. In exception classes that do not implementthe interface IF_T100_MESSAGE, the interface methods GET_TEXT and GET_LONGTEXT get the exception textsof exception objects stored in OTR (Online Text Repository), which then can be issued by using the variant of the MESSAGE statement as a message.
Example
In a local exception class lcx_exception, the interface IF_T100_MESSAGE is implemented and itsattribute T100KEY supplied with values. When the exception is handled, the statement MESSAGE displays the corresponding message, where a placeholder "&" is replaced by the content of the attribute text.
CLASS lcx_exception DEFINITION INHERITING FROM cx_dynamic_check.
PUBLIC SECTION.
INTERFACES if_t100_message.
METHODS constructor IMPORTING text TYPE csequence.
DATA text TYPE c LENGTH 40.
ENDCLASS.
CLASS lcx_exception IMPLEMENTATION.
METHOD constructor.
super->constructor( ).
me->text = text.
if_t100_message~t100key-msgid = 'SABAPDEMOS'.
if_t100_message~t100key-msgno = '888'.
if_t100_message~t100key-attr1 = 'TEXT'.
ENDMETHOD.
ENDCLASS.
DATA exc_ref TYPE REF TO lcx_exception.
START-OF-SELECTION.
TRY.
RAISE EXCEPTION TYPE lcx_exception EXPORTING text = 'Error!'.
CATCH lcx_exception INTO exc_ref.
MESSAGE exc_ref TYPE 'I' DISPLAY LIKE 'E'.
ENDTRY.
General Material Data Addresses (Business Address Services)
This documentation is copyright by SAP AG.
Length: 10603 Date: 20120523 Time: 001156 triton ( 303 ms )






