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

This addition assigns the short text of the message to the target field text. The message type does not matter. The program flow is not interrupted and no message processing takes place. The following can be specified for text:

  • An existing character-like variable.
  • An inline declaration DATA(var), where a variable of type string is declared.

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 (declared inline) when handling the exception error_message using the relevant system fields.

CALL FUNCTION... EXCEPTIONS error_message = 4.
IF sy-subrc = 4.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          INTO DATA(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 operands dobj1, ..., dobj4. Up to four operands 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. If the data type is character-like, then dobj1 through dobj4 are character-like expression positions; if it is not character-like, they are functional operand positions.

The position of an operand determines which placeholder is replaced. The formatted content of the first operand replaces the placeholders "&1", the first placeholder "&" and "&V1&", the second replaces "&2", the second "&" and "&V2&" etc. Furthermore, the formatted content of the operands dobj1, ..., dobj4 is assigned in sequence to the system fields sy-msgv1 to sy-msgv4.

If fewer operands than placeholders are specified, 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 operand 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 directly after WITH, then the values set by the current MESSAGE statement are used. If they are specified as operands of character-like expressions, the preceding values 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 operands can replace both placeholders. The operand 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'.