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

In msg a message is specified from the database table T100 either via direct specification of id and n resp. via the content of the data objects mid and num for the message class and the message number. Or, an object reference variable oref is specified, whose dynamic type implements the interface IF_T100_MESSAGE. You have to specify one of the possible message types "A", "E", "I", "S", "W" or "X", either by direct specification of t, or as content of the data object mtype, whereby the behavior of the message is controlled.

If the specified message is not found for the logon language, then the specified message type, the message class and the message number are used as short text in capital letters separated by a colon ":".

The system fields of the statement MESSAGE are always supplied with the specified values.

Alternative 1

... tn ...


Effect

With t and n you specify the one-digit message type and the three-digit message number directly in a row (static short form). The message class must be specified with the addition MESSAGE-ID at the statement that introduces the program.

Example

Display of the short text of the message with the number 014 from the message class SABAPDOCU as Information message.

REPORT rep MESSAGE-ID sabapdocu.
...
MESSAGE i014.

Alternative 2

... tn(id) ...


Effect

For t and n the same applies as for the static short form. In the static long form, the message class is specified directly in brackets through id.

Notes

Example

As example for alternative 1, with explicit specification of the message class.

REPORT ...
...
MESSAGE i014(sabapdocu).

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 objects mid, mtype and num (dynamic form). For mid and mtype, character-type data objects are expected that must contain the message class resp. the message type in capital letters. Invalid message types create an uncatchable exception. For num, a data object of the type n and the length 3 is expected.

Note

The explicit specification of the message class overrides the addition MESSAGE-ID of the statement that introduces the program.

Example

As example for alternative 2, with dynamic specification of the message and the message type.

DATA: mid  TYPE sy-msgid VALUE 'SABAPDOCU',
      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, at execution of the statement MESSAGE points at an object, whose class implements the system-interface IF_T100_MESSAGE ,which in turn contains the component-interface IF_MESSAGE. For mtype, a character-type data object is expected which must contain the message type in capital letters.

The statement MESSAGE analyses 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, the message number from the component MSGNO. If the components ATTR1 to ATTR4 contain the names of other attributes of the object, the placeholder "&1" to "&4" und "&" of the short text resp. "&V1&" to "&V4&" of the long text of the message are replaced by the content of these attributes according to the rules of usage given by the additions WITH 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

Example

In a class c1, the interface IF_T100_MESSAGE is implemented and its attribute T100KEY supplied with values. The statement MESSAGE displays the respective statement, in which a placeholder "&" is replaced with the content of the attribute text.

CLASS c1 DEFINITION.
  PUBLIC SECTION.
    INTERFACES if_t100_message.
    DATA text TYPE c LENGTH 10 VALUE 'Hello!'.
    METHODS constructor.
ENDCLASS.

CLASS c1 IMPLEMENTATION.
  METHOD constructor.
    if_message~get_text( ).
  ENDMETHOD.
  METHOD if_message~get_text.
    if_t100_message~t100key-msgid = 'SABAPDOCU'.
    if_t100_message~t100key-msgno = '888'.
    if_t100_message~t100key-attr1 = 'TEXT'.
  ENDMETHOD.
  METHOD if_message~get_longtext.
  ENDMETHOD.
ENDCLASS.

DATA oref TYPE REF TO c1.

START-OF-SELECTION.

  CREATE OBJECT oref.

  MESSAGE oref TYPE 'I'.