AS ABAP Release 758, ©Copyright 2024 SAP SE. All rights reserved.
ABAP - Keyword Documentation → ABAP - Programming Language → Text Repositories → Messages →
MESSAGE
Syntax
MESSAGE { msg | text
}
{ { [DISPLAY LIKE dtype] [WITH dobj1 ... dobj4] }
| { [DISPLAY LIKE dtype] [WITH dobj1 ... dobj4]
RAISING exception }
| {
[WITH dobj1 ... dobj4]
INTO text } }.
1. ... DISPLAY LIKE dtype
2. ... WITH dobj1 ... dobj4
Effect
The statement MESSAGE sends either the short text of a message specified in msg from the table T100 in the logon language of the current user or any text specified in text. The following variants are available:
System Fields
Name | Meaning |
sy-msgid | Contains the message class after a message is sent, and the value 00 after any text is sent. |
sy-msgno | Contains the message number after a message is sent, and the value 001 after any text is sent. |
sy-msgty | Contains the identifier of the message type with which the message or the text was sent. |
sy-msgv1 to sy-msgv4 | Contain the content of the data objects specified after the addition WITH in the order of the objects after a message is sent, and the first 200 characters of the data object text after any text is sent. |
The DDIC structure SYMSG contains components MSGTY, MSGID, MSGNO, MSGV1, MSGV2, MSGV3, MSGV4 of the same types as the above system fields and can be used to handle the properties of a message in one structured data object.
Hints
Example
Display of an information message.
MESSAGE 'Success!' TYPE 'I'.
... 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, W, S, or I 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 at PBO and LOAD-OF-PROGRAM,
are displayed as a dialog box 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.
Hints
Example
Display of an information message with the icon of a status message.
MESSAGE 'Success!' TYPE 'I' DISPLAY LIKE 'S'.
... 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, 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, 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, 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 used with the output of a text txt or when an object reference variable is specified in msg.
Hints
Example
The short text of the specified message in the table T100 contains the value & & & & and the message text This is not America is displayed as an information message. If the short text were defined as &4 &1 &3 &2, the output would be America This not is.
MESSAGE ID 'SABAPDEMOS' TYPE 'I' NUMBER '888'
WITH 'This' 'is' 'not' 'America'.
Uncatchable Exceptions