Professional Documents
Culture Documents
Messages
Messages provide another way to communicate with the user, in addition to general
screens and selection screens. They are mostly used for error handling during the
processing of other user dialogs.
Message Management
Messages are single texts, stored in table T100 that you can maintain in Transaction
SE91 or by forward navigation in the ABAP Workbench. T100 has the following
structure:
Language key
Message number
Messages
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.
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.
and a success message in the status bar of the next screen (in this case, a list).
Message Processing
Message processing depends on the message type specified in the MESSAGE
statement, and the program context in which the statement occurs.
Message Types
A
E
I
W
X
Termination
Message
Error Message
Information
Status Message
Warning
Exit
Contexts
Messages, especially those with type E or W, are processed according to the context
in which they occur.
Messages without Screens
This context applies to all situations that do not belong to any screen processing. In
ABAP programs, this includes the following processing blocks:
1
All other processing blocks are associated with screen processing (reacting to user
input).
In order to make the following table more concise, the above mentioned processing
blocks are structured into two groups.
Group 1: LOAD-OF-PROGRAM, PBO module of screens, AT SELECTION-SCREEN
OUTPUT
Group 2: Reporting and list events (INITIALIZATION, START-OF-SELECTION, GET,
END-OF-SELECTION, TOP-OF-PAGE and END-OF-PAGE)
Message Processing
Typ
Display
Processing
e
A
Dialog box
current window
..............next screen
MESSAGE statement
..............next screen
Group 2: Status line of the
...............current window
None
Messages on Screens
This context includes all situations where a screen is being processed, that is, the
program is reacting to user input. In ABAP programs, this means all PAI modules.
Message Processing
Typ
Display
Processing
Dialog box
e
A
area menu
E
Status bar
Dialog box
Program
continues
processing
after
the
processing
after
the
MESSAGE statement
S
Program
continues
MESSAGE statement
W
Status bar
directly
after
the
MESSAGE
None
Display
Processing
Dialog box
e
A
area menu
E
Status line
AT
then
restarts
the
selection
screen
Dialog box
Program
continues
processing
after
the
processing
after
the
MESSAGE statement
S
Program
continues
MESSAGE statement
W
Status line
None
Messages in Lists
This context includes all situations where a list is being processed, that is, the
program is reacting to user interaction with lists. In ABAP programs, this includes the
following processing blocks:
1
AT LINE-SELECTION
AT USER-COMMAND
AT PFnn
Typ
e
Display
Processing
Dialog box
Status bar
Dialog box
Status bar
Like type E
None
If the calling program does not handle the exception, the message is displayed
and handled according to the context in which it occurs in the function module or
method from which it was called.
If the calling program handles the exception, the message is not displayed.
Instead, the procedure is interrupted in accordance with the message type, and
processing returns to the calling program. The contents of the message are
placed in the system fields sy-msgid, sy-msgty, sy-msgno, and sy-msgv1
through sy-msgv4 .
Type X messages trigger the usual runtime error and short dump.
Maintaining Messages
Messages allow you to communicate with users from your programs. They are mainly
used when the user has made an invalid entry on a screen.
To send messages from a program, you must link it to a message class. Each
message class has an ID, and usually contains a whole set of message.
Each message has a single line of text, and may contain placeholders for variables.
All messages are stored in table T100. You create and edit them using Transaction
SE91. Once you have created a message, you can use it in the MESSAGE statement
in a program.
You can display the messages for your program from the ABAP Editor by
choosing Goto Messages. The Maintain Messages screen appears. By
default, the system display the message class linked to the current program.
If you choose Goto Messages from the ABAP Editor and your program does not
have a defined message class, the system assumes you want to browse an existing
class and prompts you for a message class ID.
Creating Message Classes
Procedure
To create a new message class from the ABAP Editor:
1. In the initial statement (for example, REPORT) or directly in the statement
MESSAGE ID <id> enter a parameter value of up to 20 characters as a
message ID, for example:
REPORT <name> MESSAGE-ID <message class>.
Messages are stored system-wide. The chosen message ID (message class)
must not already exist in the system.
2. Double-click the message ID.
If you enter an ID that already exists in the system, the system calls up
Message maintenance. In this case, enter a different ID. Once you have done
this, the system asks you whether you want to create a new message class.
3. Choose Yes.
The system calls up Message maintenance.
4. Enter a brief description of the class in Short text.
5. Choose Save.
Result
You can add messages to your class by choosing the Messages tab. You can always
return to the Message maintenance screen by double-clicking a message ID or a
message number where it appears in your code.
Adding Messages
Assuming that a valid message class exists in the ABAP program:
1. Choose the menu path Goto Messages
The system displays a list of all messages belonging to the message class.
2. Select