Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  User Dialogs →  Messages →  MESSAGE 

MESSAGE - message_options

Short Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


... { {[DISPLAY LIKE dtype] [RAISING exception]} 
    | [INTO text] }

    [WITH dobj1 ... dobj4].

Extras

1. ... DISPLAY LIKE dtype

2. ... INTO text
3. ... WITH dobj1 ... dobj4

Effect

These additions change the display mode, assign the text of the message to a data object and replace the placeholders in the short texts and long texts of messages.

The statement MESSAGE uses the addition RAISING to trigger a non-class-based exception in function modules or methods.

Addition 1

... DISPLAY LIKE dtype

Effect

When this addition is used, the icon of the message type specified in dtype is displayed instead of the associated icon. dtype expects a character-like data objects containing one of the values "A", "E", "I", "S", or "W" in uppercase letters.

For messages displayed in a dialog box by default, the short text is still displayed as a dialog box. Messages with the type "E" or "W" (except those for PBO and LOAD-OF-PROGRAM) are displayed as a dialog window if dtype contains "A" or "I". Messages with the type "S" are always displayed in the status bar, regardless of the dtype. The latter also applies to messages of the type "I" for PBO and LOAD-OF-PROGRAM. Messages of the type "X" always cause a runtime error.


Notes

  • The usage of this addition does not influence the behavior determined by the message type, but only the type of display.
  • Specifying "X" for dtype is not recommended, since no icon is assigned to this message type.

Addition 2

... INTO text

Effect

You use this addition to assign the short text of the message to the variable text. The message type does not matter. The program flow is not interrupted and no message processing takes place. text expects a character-like data object.

The addition INTO cannot be specified in the output of a user-defined text.


Example

The short text of a message sent in a function module is assigned to the data object mtext when handling the exception error_message using the relevant system fields.

      DATA mtext TYPE string.
      CALL FUNCTION ... EXCEPTIONS error_message = 4.
      IF sy-subrc = 4.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                INTO mtext
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.

Addition 3

... WITH dobj1 ... dobj4

Effect

This addition replaces the placeholders "&1" to "&4" and "&" of the short text or "&V1&" to "&V4&" of the long text of the message with the formatted content of the data objects dobj1, ..., dobj4. Up to four data objects dobj1 through dobj4 can be specified. They can have the same data type as a source field of the statement WRITE TO and they are formatted in accordance with the associated predefined formats with an output length of 50. The position of a data object determines which placeholder will be replaced. The formatted content of the first data object replaces the placeholders "&1", the first placeholder "&" and "&V1&", the second replaces "&2", the second "&" and "&V2&" etc. Furthermore, the formatted content of the data objects dobj1, ..., dobj4 is assigned in sequence to the system fields sy-msgv1 to sy-msgv4.

If you specify fewer data objects than placeholders, then surplus placeholders are not displayed in the short text and the associated system fields sy-msgv1 to sy-msgv4 are initialized. If a specified data object cannot be assigned to a placeholder, it is ignored.

If the system fields sy-msgid, sy-msgno, and sy-msgv1 through sy-msgv4 are specified after WITH, then the values set by the current MESSAGE statement are used.

The addition WITH cannot be specified at the output of an user-defined text, or an object reference oref.


Notes

  • If a short text contains placeholders of both forms "&i" and "&", then the content of a data object can replace both placeholders. The data object at the position i not only replaces "&i" but also the i-th placeholder at position "&". We recommend that only one of the two forms for placeholders are used in a short text. If a short text is to be translated into other languages, only the numbered placeholder "&i" can be used, since the structure of the sentence may change.
  • For reasons of downward compatibility, the character "$" is handled in the same way as "&" in short texts. The same is true for "$i". Therefore, "$$" must be specified if "$" is to be displayed.
  • In longtexts, the placeholders from "&V1&" to "&V4&" must be stored as such in the database. If theGraphical PC Editor is being used, they cannot be entered directly, but must be inserted using Insert → Symbols → Text Symbols.

Example

If the short text of the specified message in the table T100 contains the value "& & & &" , then the text "This is not America" is displayed as an information message. If the short text was defined as "&4 &1 &3 &2" , then the output is "America This not is".

MESSAGE i010 WITH 'This' 'is' 'not' 'America'.