ERPClimb logoERPClimb
ABAP Core
ABAP Developmentbeginner 8 min read

ABAP Core Part 8: Messages and User-Friendly Error Handling

Preview · a free account unlocks the full lesson

Key takeaway

Use messages correctly: message classes and numbers, message types (S, I, W, E, A, X) and their behavior in different contexts, placeholders, MESSAGE … INTO for logging, and collecting messages instead of stopping at the first error.

In this lessonShow sections

Visual overview

ABAP Core Part 8: Messages and User-Friendly Error Handling — learning sheetFlow: Create message class ZFLIGHT with messages 001–003 → Use them in the report as in the code example → Try types S, I, W, E and observe the behavior → Collect messages with MESSAGE … INTO and display them together. Key ideas: MESSAGE CLASSES; SENDING A MESSAGE; MESSAGE TYPES AND BEHAVIOR (CLASSIC REPORTS); MESSAGES IN REUSABLE CODE. Watch out: WATCH OUT: in background jobs, function modules and RFC, E/A messages behave differently (e.g. cancel the job or become exceptions) — do not use MESSAGE E deep inside reusable code.ERPClimb.com / ABAP / LESSON 8/10 / LEARNING SHEETABAP Core Part 8: Messages and User-Friendly ErrorHandling1 · HOW IT FLOWS1Create messageclass ZFLIGHTwith messages…2Use them in thereport as in thecode example3Try types S, I,W, E and observethe behavior4Collect messageswith MESSAGE …INTO and display…2 · KEY IDEAS EXPLAINEDMessage ClassesCreate a message class (e.g. ZFLIGHT) withnumbered texts:Sending A MessageMESSAGE e001(zflight) WITH p_carr.Message Types And Behavior (Classic…S — status bar message; processing continues.I — information popup; processing continues afterconfirmation.Messages In Reusable Coderaise exceptions (Part 9) orreturn messages in a table (BAPIRET2 style) or3 · REMEMBER · WATCH OUTRememberMessages live in message classes (SE91 / ADT) with a number and up to4 placeholders (&1–&4).Type decides behavior: S (status), I (info popup), W (warning), E(error), A (abort), X (dump).The same type behaves differently by context (selection screen, list,dialog, background, RAP).!Watch outWATCH OUT: in background jobs,function modules and RFC, E/Amessages behave differently (e.g.cancel the job or become exceptions)— do not use MESSAGE E deep insidereusable code.4 · IN A REAL PROJECTA mass upload program stopped at the first invalid line with MESSAGE E, so users fixed one error, restarted,hit the next error, and needed a dozen runs for one file. In background mode the job simply cancelled withlittle context. The redesign validated all lines first, collected messages with MESSAGE … INTO into a BAPIRET2…Original ERPClimb learning sheet • Verify against your SAP release and edition

Explanation

Part 5 showed an error message appearing on the selection screen without really explaining how messages work. This part covers them properly.

Messages live in message classes, maintained in SE91 or in ADT, each with a number and up to four placeholders, &1 through &4. A message class such as ZFLIGHT might contain numbered texts like 001 Airline &1 does not exist, 002 No authorization for airline &1, and 003 Flight &1 &2 on &3 is fully booked. These texts are translatable, which is exactly why user-facing messages should never be hard-coded directly in the program.

Sending a message is simple: MESSAGE e001(zflight) WITH p_carr. or, in its more structured form, MESSAGE ID 'ZFLIGHT' TYPE 'E' NUMBER '001' WITH p_carr.

The message type decides its behavior: Type decides behavior: S (status), I (info popup), W (warning), E (error), A (abort), X (dump).

In classic reports, S produces a status-bar message and processing simply continues; I shows an information popup and continues once the user confirms it; W shows a warning that the user can confirm and continue past, on screens; E, on a selection screen or dynpro, forces the user to correct their input, while in START-OF-SELECTION it instead ends the processing and displays the message; A terminates the whole transaction; and X triggers a short dump, reserved for genuinely impossible situations.

The same type behaves differently by context (selection screen, list, dialog, background, RAP) — in background jobs, function modules and RFC calls specifically, E and A messages behave quite differently, for instance canceling the job outright or turning into exceptions, which is exactly why MESSAGE E should never be used deep inside reusable code.

Free account

Create a free account to keep reading

You have read the opening of this lesson. A free ERPClimb account unlocks the rest of it, every other lesson and topic, and your learning history, so you can pick up exactly where you stopped. No card needed.

  • Full explanation
  • Code example
  • Real project scenario
  • Common mistakes
  • Best practices
  • Interview angle

One tap with Google works too. Every topic keeps its first lesson open to everyone.

Keep exploring

Referenced SAP objects

Reviewed reference pages for the objects this page mentions.

Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.