DownLoad PDF

In ABAP you need to display a message on various occasions, for example if the user has input erroneous data then a message needs to be displayed, instructing the user to rectify the error, or after a certain task is accomplished, you may need to display a message.
A message class is used to display messages from the program and the transaction used for this purpose is SE91. The messages are stored in the table T100. Examples of calling a message are shown below.
You may need to create a message class for displaying your message. You need to check if a message class has already been created by other ABAP colleagues. Note that messages classes would already exist in your system, but you may have to create a new class for your programs.
To create a new message class type the name following the naming standards and type the name as shown in the figure below. Alternatively you can goto transaction SE91 to create a new message class.
In this example we will type the name as shown below and double click on the name 'ZEXERCISE1'.

The following prompt will appear. Click on Yes.

Click on Yes again.

Type an appropriate short text.

Create a $tmp object

Type a message that you would like to display. Please note the number associated with the message. In this case the message is '000'.

We have created 3 messages.

We now need to display these messages in our program. We will make changes in the Create Sales order program as shown below.
Some examples of calling a message.
1. MESSAGE xnnn.
2. MESSAGE ID id TYPE mtype NUMBER n.
3. MESSAGE xnnn(mid).
There are six kinds of message type:
- A (Abend)
- Termination
- E (Error)
- Error
- I (Info)
- Information
- S (Status)
- Status message
- W (Warning)
- Warning
- X (Exit)
- Termination with short dump
See the syntax shown below for displaying a message in your programs.
MESSAGE ID id TYPE mtype NUMBER n.
- ID
- message class in our case ZEXERCISE1 or ZEXERCISE2
- TYPE
- message type (A,E,I,S,W,X)
- NUMBER
- message number
Example
MESSAGE ID 'ZEXERCISE' TYPE 'S' NUMBER '000'.

Once the program is run the messages will be displayed as follows. Choose the one that suits your requirement.


The following message is displayed just to show as to how to explicitly call another message class.
