
Types of Messages used for SAP the ABAP program (A, E, W, I, S) explained with examples
If you've ever been involved in SAP development, you are aware that communicating accurate details to users at the right moment is as crucial as writing code that is clean. SAP ABAP is a dependable and well-structured messaging system that lets developers display error messages, warnings, messages, warnings, confirmations, and other informational texts with a consistent style for the entire range of SAP applications. No matter if you're beginning your journey or an experienced consultant who is brushing on the fundamentals, this guide takes you through all you must know about messages and types that are available in SAP ABAP — for example, how to make messages classes, utilize interactive messages, and show pop-up messages, with examples of how to use them.
What Is a Message in SAP ABAP?
The SAP ABAP message can be described as a text-based message that is displayed to the user during the program's execution. The messages are used to inform users of the status of an operation — whether the data has been successfully saved, the required field is not present, or an error of critical importance occurs that prevents further processing.
Text messages within SAP ABAP are initiated by the MESSAGE command. They can be coded inside the line and, with more professionalism, stored and managed in a class called a message — a reusable repository for messages that are managed by SE91.
Message Class in SAP ABAP
An object called a message in SAP ABAP is an object container that holds messages in numbered text. Instead of coding messages in the program, it is possible to define these one time within a class called a message and use them as a reference to their class name as well as number. This helps your code become cleaner, simpler to keep, and ready for translation in multiple languages in SAP environments.
How to Create a Message Class in SAP ABAP
Making a message class is easy. These are the steps to follow:
- You can find the transaction SE91 within the SAP system.
- Give a name to your class (up to 20 characters) in the Message Class field.
- Click Create.
- Write a brief description of the message type.
- Go to the tab titled Messages.
- Input message numbers (000 to 999) together with the appropriate message text.
- You can add up to four placeholders by using the characters &1, &2, &3, and &4 for dynamic values.
- Save and enable the class of message.
Once you have created your message class, your message class will be accessible to use in all ABAP software, functional module, or class within the system.
Types of Messages in SAP ABAP
SAP ABAP supports five standard types of messages, each one identified with a letter. Knowing what and when to use the different types is crucial to creating professional, user-friendly SAP software.
Message Type A — Abend (Termination)
The type of message A within SAP ABAP causes immediate program end. If an A-type message occurs, the current transaction will be ended, an unintentional dump is not created, however, the user is taken back to SAP Easy Access menu or the call screen. A dialog box shows the message's text prior to closing.
Make use of message type A if an issue is so crucial that a continuation of the program could cause data inconsistency or system problems.
Example:
MESSAGE a001(zmessage_class).
Inline:
MESSAGE a001(zmessage_class) WITH 'Order' 'cannot be handled'.
Message Type E — Error
An error message within SAP ABAP stops the current processing process and emphasizes the field or screen which caused the error. The user needs to rectify the input prior to proceeding. When processing in the background, an error message from the E-type will cause the task to stop with an error code.
Error messages are among the most often used type of message in dialog applications, verifications, or BAPIs.
Example:
IF lv_quantity <= 0.
MESSAGE e002(zmessage_class) WITH lv_quantity.
ENDIF.
Message Type W — Warning
The warning message in SAP ABAP alerts the user to a possible issue, but it doesn't stop the process. The user can see the message within the status bar that appears at the lower part of the screen. They can decide whether to continue or return to correct the input. In background tasks, alert messages will be recorded but they do not trigger an end to the job.
Use W-type messages for messages that are designed to grab the attention of your user without hindering their work.
Example:
IF lv_stock < lv_min_threshold.
MESSAGE w003(zmessage_class) WITH lv_stock.
ENDIF.
Message Type I — Information
A message with information that is displayed in SAP ABAP displays a popup dialog box that displays the message's text. Users must select OK to close the popup and proceed. Sometimes, this is known as a pop-up warning when using SAP ABAP because of the dialog it produces.
Use I-type messages if you wish to share important information that needs acknowledgement from the user before proceeding.
Example:
MESSAGE i004(zmessage_class).
This is among the most commonly used methods to set up a pop-up message inside SAP ABAP without needing to create a function module separately.
Message Type S — Success
A message of success in SAP ABAP displays a confirmation text in the status bar at the bottom of the screen following an operation that was successful. It's non-blocking, meaning the user doesn't have to perform any actions. The message appears for a brief moment and disappears after the next screen appears.
Utilize S-type messages to verify that an action, such as saving an entry, posting a document, or changing a field was successfully completed.
Example:
MESSAGE s005(zmessage_class) WITH lv_doc_number.
Quick Reference: SAP ABAP Message Types Summary
| Message Type | Letter | Behavior | Use Case |
|---|---|---|---|
| Abend | A | Ends the transaction immediately | Critical system failures |
| Error | E | Stops processing, highlights field | Field validation, mandatory checks |
| Warning | W | Alerts the user, does not stop processing | Threshold checks, soft validations |
| Information | I | Dialog popup, user clicks OK to continue | Important notifications requiring acknowledgment |
| Success | S | Status bar confirmation, non-blocking | Post-save or post-action confirmations |
Dynamic Message in SAP ABAP
A dynamic message within SAP ABAP lets you add runtime variable values to the message text by using placeholders. These messages are more contextual and much more valuable to users as opposed to static, plain text.
Within your message class (SE91), define the message text by using &1, &2, &3, or &4 as placeholders. Then, you can pass the values through the WITH option in the MESSAGE statement.
Display the Message with Variable in SAP ABAP
Message text in SE91 (Message 006):
Material & is not available in plant &
ABAP code:
MESSAGE e006(zmessage_class) WITH lv_material lv_plant.
Output displayed to user:
Material MAT001 is not available in plant 1000
You can pass up to four variables with a single message statement. This is the standard way to format message in SAP ABAP with dynamic, context-specific content.
Popup Message in SAP ABAP
There are two main ways to implement a popup message in SAP ABAP:
Method 1: Using Message Type I
As covered above, message type I automatically displays a modal popup dialog with the message text. This is the simplest approach and requires no additional function module calls.
MESSAGE i007(zmessage_class) WITH lv_order_number.
Method 2: Using POPUP_TO_CONFIRM Function Module
For more control over the popup — including Yes/No buttons, custom title, and conditional logic based on the user's response — use the standard function module POPUP_TO_CONFIRM.
DATA: lv_answer TYPE c LENGTH 1.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
titlebar = 'Confirm Deletion'
text_question = 'Do you want to delete this record?'
text_button_1 = 'Yes'
text_button_2 = 'No'
IMPORTING
answer = lv_answer.
IF lv_answer = '1'.
" User clicked Yes — proceed with deletion
ENDIF.
This method gives you full control over the dialog and is particularly useful in confirmation workflows where you need the user to actively approve a destructive or irreversible action.
Using Messages in Different ABAP Contexts
Messages in Dialog Programs (Module Pool)
In module pool programming, messages behave slightly differently depending on where they are triggered. An E-type message raised inside a PAI module returns the user to the same screen with the field highlighted. An A-type message terminates the transaction entirely.
MODULE validate_input INPUT.
IF sy-ucomm = 'SAVE'.
IF lv_name IS INITIAL.
MESSAGE e008(zmessage_class).
ENDIF.
ENDIF.
ENDMODULE.
Messages in Reports and Executable Programs
In report programs, the MESSAGE statement works as expected. However, note that E-type messages in reports display in the status bar and halt execution at that point, similar to their behavior in dialog programs.
REPORT zmy_report.
START-OF-SELECTION.
IF p_date IS INITIAL.
MESSAGE e009(zmessage_class).
ENDIF.
Messages in Function Modules and Classes
In function modules and ABAP OO classes, you typically raise exceptions rather than use MESSAGE statements directly. However, when MESSAGE is used with the RAISING addition, it can pass message details back to the calling program through the exception interface.
FUNCTION z_check_material.
IF lv_matnr IS INITIAL.
MESSAGE e010(zmessage_class) RAISING material_not_found.
ENDIF.
ENDFUNCTION.
Inline Messages Without a Message Class
For quick prototyping or simple programs, you can define messages inline without referencing a message class at all. While this is not recommended for production code, it is useful during development and testing.
MESSAGE 'Please enter a valid date.' TYPE 'E'.
Or using the shorthand:
MESSAGE e000 WITH 'Quick error message'.
For production-grade programs, always use a properly maintained message class. It improves maintainability, supports translation, and keeps your codebase clean and consistent.
Best Practices for SAP ABAP Messages
Following these practices will ensure your message implementation is professional, maintainable, and user-friendly:
- Always create a dedicated message class for each development package or application area rather than reusing generic ones.
- Use descriptive, action-oriented message texts. Instead of "Error occurred", write "Material & could not be saved in plant &".
- Reserve message type A strictly for situations where continuing would risk data integrity. Overusing abend messages frustrates users.
- Use S-type messages consistently after every successful save or post operation so users always receive confirmation.
- Avoid hardcoding message strings in production code. Always store texts in SE91 for translatability and easy maintenance.
- Use dynamic placeholders (&1 to &4) to make messages informative and context-specific.
- Test all messages in both dialog and background processing contexts, as their behavior differs between the two.
Frequently Asked Questions
What is the difference between message type E and A in SAP ABAP? An E (Error) message stops the current processing step and returns control to the user for correction without ending the transaction. An A (Abend) message immediately terminates the entire transaction and returns the user to the main menu.
How do I create a message class in SAP ABAP? Use transaction SE91, enter a name and description, add numbered messages with optional placeholders (&1 to &4), and activate. The class can then be referenced in any ABAP program using the MESSAGE statement.
What is a dynamic message in SAP ABAP? A dynamic message uses runtime variable values passed via the WITH addition to populate placeholder fields in the message text, making the output specific and informative rather than generic.
Which message type creates a popup in SAP ABAP? Message type I (Information) automatically displays a popup dialog box that requires the user to click OK before continuing. For more advanced popups with custom buttons, use the POPUP_TO_CONFIRM function module.
Can I use messages in ABAP OO classes? Yes. You can use the MESSAGE statement inside methods. For function modules and methods, combining MESSAGE with the RAISING addition allows you to pass message context through exceptions back to the caller.
Conclusion
Mastering SAP ABAP messages is one of those foundational skills that immediately improves the quality and professionalism of everything you build. From displaying a clean error message in SAP ABAP during field validation, to confirming a successful posting with an S-type message, to triggering a popup message in SAP ABAP that requires user acknowledgment — the MESSAGE statement and message class framework give you everything you need to communicate clearly with your users.
Whether you are just learning how to create a message class in SAP ABAP for the first time or looking to implement dynamic messages with variable values across a complex application, the principles covered in this guide apply directly to real-world SAP development. Use them consistently and your programs will not only work correctly — they will feel polished and trustworthy to the people who use them every day.
Want to go deeper into SAP ABAP development? Explore our hands-on training programs at ERPVITS and build the skills that SAP employers are actively looking for.