Show TOC

MessagesLocate this document in the navigation structure

Use

You send messages in the logon language of the current user using the ABAP statement MESSAGE . The statement specifies the message class, number, and type of the message.

The message class and number are used to identify the message in table T100. The message type is one of A, E, I, S, W, or X, and defines how the ABAP runtime should process the message .

Messages can either be displayed in modal dialog boxes, or in the status bar of the screen. How a message is processed depends on its type and on the context in which the message is sent.

The MESSAGE Statement

The MESSAGE statement has three variants and several additions:

Using a Global Message Class

If the introductory statement of a program contains the addition

... MESSAGE-ID id .

and a message class id contained in table T100, you can use the MESSAGE statement as follows:

MES SAGE tnnn [WITH f 1 ... f 4 ] [RAISING exc ].

where t is the single-character message type and nnn the three-digit message number. The system retrieves the corresponding message text from table T100 for the message class specified in the introductory statement, and displays it. The display depends on the message type and the context in which the message is sent.

Specifying the Message Statically

To specify the message class, message number, and message type statically, use the following form of the MESSAGE statement:

MESSAGE tnnn(id) [WITH f1 ... f4] [RAISING exc ].

This statement is like the first variant, but here you specify the message class id within the MESSAGE statement. This specification overrides any message class that you may have specified at the beginning of the program.

Specifying the Message Dynamically

To specify the message class, message number, and message type dynamically, use the following form of the MESSAGE statement:

MESSAGE ID id TYPE t NUMBER n [WITH f1 ... f4 ] [RAISING exc ].

where id , t and n are fields containing the message class, message number, and message type respectively. The system uses the field contents to read the appropriate message from table T100 and displays it according to the message context.

Filling Message Texts Dynamically

Message texts in table T100 can contain up to four ampersand characters ( &) as placeholders. You can replace these at runtime using the WITH addition in the MESSAGE statement:

MESSAGE ... WITH f 1 ... f 4 .

The contents of fields f 1 ... f 4 are then inserted sequentially into the message text in place of the placeholders.

Messages and Exceptions

Within function modules and methods, you can use the RAISING addition in the MESSAGE statement to trigger exception:

MESSA GE ... RAISING exc .

If the calling program does not handle the exception exc itself, the message is displayed, and the program continues processing in the manner appropriate to the message type and context. If the calling program handles the exception, the message is not displayed, but the exception is triggered. In this case, the message class, message number, message type, and any values of placeholders are placed in the system fields sy-msgid , sy-msgno , sy-msgty and sy-msgv1 to sy-msgv4 in the calling program.

Example
        
REPORT demo_messages_simple MESSAGE-ID sabapdocu.
        
MESSAGE i014.
        
MESSAGE s015.
        
WRITE text-001.
         

This simple message displays an information message in a modal dialog box:

and a success message in the status bar of the next screen (in this case, a list).