Debugging & Error Handling in ABAP (2026 Guide)

ABAP Debugging & Error Handling: Complete Guide 2026 | ABAP Zero to Hero
ABAP Zero to Hero

Chapter 11  ·  Real-World Skills

Debugging & Error Handling

How to find bugs in your code, handle errors gracefully, and understand ABAP messages — the skills that separate juniors from professionals.

Chapter 11 of 20 19 min read Part 3: Real-World 8 Interview Q&A

You can write code. But can you fix it when it breaks? That is the real test of an ABAP developer. In every project you will join, you will spend more time debugging existing code than writing new code. And when your own code fails, you need to handle errors gracefully — not let the program dump on the user’s screen.

This chapter gives you the two essential survival skills every ABAP developer needs: debugging (finding what went wrong) and error handling (making sure it never dumps on the user).

Why this chapter matters Interviews often test whether you can think like a debugger. “A user reports that a report shows wrong totals — how do you investigate?” Your answer to this separates you from candidates who only know syntax.

🎯 What You Will Learn in This Chapter

  • How to activate and use the ABAP Debugger
  • How to set breakpoints and watchpoints
  • The difference between session and external breakpoints
  • How to read a short dump and find the root cause
  • How to handle errors with TRY / CATCH and class-based exceptions
  • All six MESSAGE types (A, E, W, I, S, X) and when to use each
  • How to debug a background job (the tricky one)
  • Introduction to ST05 and SAT for performance analysis

🐞 What is Debugging?

Debugging is the process of pausing a running program, inspecting its state, and stepping through it line by line to find the source of a problem.

Imagine reading a 500-page book and you need to know what a specific character says on page 247. You would not read all 500 pages. You would skip to page 247 and read carefully from there. Debugging works the same way — you jump to the exact line where the problem occurs and watch what happens.

Without DebuggerWith Debugger
Print variables with WRITE statements and guessInspect any variable at any moment
Read code and try to trace mentallyWatch code execute step by step
Modify code just to add a messageZero code changes needed
Hours of guessingMinutes of precision

🛠 The ABAP Debugger — Two Flavors

SAP provides two debuggers:

DebuggerWhen Used
Classic DebuggerOlder, simpler, works in most transactions. Activated by /h in the command field.
New DebuggerModern, feature-rich, uses Eclipse or SAP GUI. Activated by /h or /hs (system debugging).

How to activate the debugger

1 Method 1 — Command field

Type /h in the command field (top-left of SAP GUI) and press Enter. This activates debugging for the next screen the program shows.

2 Method 2 — Set a breakpoint in the editor

Open your program in SE38 or SE80. Click on the line number area next to a code line. A small red dot appears — that is a breakpoint. The program will pause when it reaches that line.

3 Method 3 — ABAP statement

Add a BREAK-POINT. statement in your code. This is the same as setting a breakpoint in the editor, but permanent in the source code (not recommended for production).

🎮 Debugger Controls — The Buttons That Matter

Once the debugger opens, you will see a toolbar. These are the buttons you will use most:

ButtonShortcutWhat It Does
Step Over (Single Step)F6Executes the current line and moves to the next
Execute (Return)F8Runs the program until the next breakpoint
Step Into (Step Into)F5Jumps inside a FORM, method, or function module
Step Out (Return)Shift+F8Exits the current routine back to the caller
Continue (Play)F8Continues until the next breakpoint or program end
Watchpoint—Pause when a variable changes value
Table—View internal table contents
Breakpoints—List of active breakpoints
The two most important buttons F6 (Step Over) runs one line at a time. F8 (Execute) runs to the next breakpoint. If you only remember two buttons, remember these.

🎯 Breakpoints vs Watchpoints

These are the two core debugging tools. Understanding the difference will save you hours.

Breakpoints — pause at a specific line

A breakpoint stops the program when execution reaches a specific line of code. You set it where you suspect the bug is.

" Set a breakpoint here to inspect before this line runs
SELECT * FROM scarr INTO TABLE @DATA(lt_scarr).
BREAK-POINT.  " Program pauses here
LOOP AT lt_scarr INTO DATA(ls_scarr).
  WRITE ls_scarr-carrname.
ENDLOOP.

Watchpoints — pause when a variable changes

A watchpoint does not care about the line — it stops when a specific variable changes value. This is incredibly powerful for tracking down where data gets corrupted.

When to use a watchpoint You see a variable with the wrong value at the end of the program, but you do not know where it changed. Set a watchpoint on it and the debugger will pause at the exact line that modifies it.

Session vs External breakpoints

TypeScopeUse Case
Session BreakpointOnly your sessionDebugging your own code in your current session
External BreakpointAny session (including HTTP/RFC)Debugging web services, RFC calls, or another user’s session

💥 Reading a Short Dump

A short dump is what SAP calls a runtime error. It happens when your program does something illegal — dividing by zero, accessing a non-existent table row, referencing a null object.

When a dump occurs, SAP shows the user a screen with technical details. As a developer, you read those details to find the cause.

Where to find dumps

  • ST22 — Transaction to view all dumps in the system
  • Runtime error screen — The dump itself shows the error text and where it occurred

Common dump types and their causes

DumpCauseFix
COMPUTE_INT_ZERODIVIDEDividing by zeroCheck divisor before dividing
ITAB_ILLEGAL_INDEXAccessing an internal table row that does not existCheck sy-subrc or table lines before reading
DBIF_RSQL_INVALID_RSQLInvalid Open SQL statementCheck syntax and table names
OBJECTS_OBJREF_NOT_ASSIGNEDCalling a method on a null object referenceCheck IS BOUND before calling
CONVT_NO_NUMBERConverting non-numeric string to numberValidate input before conversion

📢 MESSAGE Types — A, E, W, I, S, X

Every message in ABAP has a type. The type determines how the message appears and what happens after it.

TypeNameEffectUse Case
AAbendTerminates the transaction with a dumpCritical errors (rarely used)
EErrorShows an error message, stops processingValidation failures
WWarningShows warning, allows user to continueNon-blocking issues
IInformationPopup with OK button, continuesInformation dialogs
SSuccessShows on status bar, continuesConfirmation (“Saved successfully”)
XExitTerminates silently with a dumpEmergency exits (rarely used)

MESSAGE statement syntax

" Using a message from message class ZMSG
MESSAGE e001(zmsg).                " Error type, message 001

" With dynamic text
MESSAGE i001(zmsg) WITH lv_name.

" Inline syntax (modern)
MESSAGE |Error: { lv_msg }| TYPE 'E'.

" Check message type in code
IF sy-subrc <> 0.
  MESSAGE 'Record not found' TYPE 'E'.
ENDIF.
MESSAGE TYPE ‘E’ behavior When you use MESSAGE ... TYPE 'E' in a report, the program stops. Use TYPE 'W' or TYPE 'I' if you want the program to continue.

🛡 Exception Handling — TRY / CATCH

Exception handling is the art of catching errors before they crash the program. ABAP has two approaches: classic exceptions (older) and class-based exceptions (modern, recommended).

Class-based exceptions — TRY / CATCH

Modern exception handling uses TRY and CATCH blocks. The idea: run code inside TRY. If an exception is raised, control jumps to CATCH.

TRY.
    DATA(lv_result) = 10 / iv_divisor.
    WRITE: / 'Result:', lv_result.

  CATCH cx_sy_zerodivide INTO DATA(lo_exc).
    WRITE: / 'Cannot divide by zero!'.
    WRITE: / lo_exc->get_text( ).

  CATCH cx_root INTO DATA(lo_root).
    WRITE: / 'Unexpected error:', lo_root->get_text( ).

ENDTRY.

Raising exceptions

When writing your own classes, you can raise exceptions intentionally to signal problems:

CLASS zcl_validator DEFINITION.
  PUBLIC SECTION.
    METHODS validate
      IMPORTING iv_amount TYPE p
      RAISING   cx_sy_arithmetic_error.
ENDCLASS.

CLASS zcl_validator IMPLEMENTATION.
  METHOD validate.
    IF iv_amount < 0.
      RAISE EXCEPTION TYPE cx_sy_arithmetic_error.
    ENDIF.
  ENDMETHOD.
ENDCLASS.

Classic exceptions — EXCEPTIONS parameter

Older function modules use the EXCEPTIONS parameter. You list possible exceptions and check sy-subrc after the call:

CALL FUNCTION 'Z_VALIDATE_DATE'
  EXPORTING
    iv_date = sy-datum
  EXCEPTIONS
    invalid_date = 1
    others       = 2.

IF sy-subrc = 1.
  WRITE: / 'Date is invalid.'.
ENDIF.
Which to use Class-based (TRY/CATCH) for all new code. Classic (EXCEPTIONS) when calling older function modules that do not support class-based exceptions.

⚙️ Debugging a Background Job

Background jobs run without a user session, so you cannot just type /h. But you can still debug them. Three approaches:

Approach 1 — Debug background job from SM37

  1. Go to transaction SM37 (Job Overview)
  2. Find and select the job
  3. Click Job → Debug (or the Debug button)
  4. A dialog appears asking for a user. Enter your username
  5. Release the job. When it starts, your debugger opens

Approach 2 — WAIT UP TO statement

WAIT UP TO 10 SECONDS.  " Creates a debugging window

Approach 3 — Remote debugging

For RFC and HTTP calls, configure remote debugging in the target system so calls from a specific user trigger the debugger automatically.

📊 ST05 and SAT — Performance Tools (Intro)

Debugging is not only about bugs. It is also about performance. Two tools you must know:

ToolFull NameWhat It Does
ST05SQL Performance TraceRecords all database calls (SELECT, INSERT, UPDATE, DELETE). Use it to find slow or excessive DB queries.
SATRuntime AnalysisMeasures execution time of ABAP code at the statement level. Use it to find which methods or statements take the longest.
Which one to use ST05 when the database is slow. SAT when your own ABAP code is slow. These are covered in depth in Chapter 15 (Performance Tuning).

📝 Chapter Summary

  • The ABAP Debugger pauses execution so you can inspect variables and program flow.
  • Activate it with /h in the command field, or set a breakpoint in the editor.
  • F6 = Step Over (next line). F8 = Execute to next breakpoint.
  • Breakpoints pause at a specific line. Watchpoints pause when a variable changes value.
  • A short dump is a runtime error. Read it in ST22 to find the cause.
  • Six MESSAGE types: A (Abend), E (Error), W (Warning), I (Info), S (Success), X (Exit).
  • Class-based exceptions use TRY / CATCH. Use them for all new code.
  • Debug background jobs via SM37 → Job → Debug.
  • ST05 traces database calls. SAT measures code execution time.

🎤 Interview Questions & Answers

These are real interview questions about debugging and error handling. Being able to describe your debugging approach clearly is often more important than knowing every syntax detail.

1 What is the ABAP Debugger and how do you use it?

The ABAP Debugger is a built-in tool in SAP that lets you pause program execution and inspect variable values, internal table contents, and program flow step by step. You activate it by setting a breakpoint in the editor or by typing /h in the command field. Once triggered, the debugger opens and you can step through code line by line.

2 What is the difference between a breakpoint and a watchpoint?

A breakpoint pauses the program at a specific line of code. A watchpoint pauses the program when a specific variable changes value, regardless of which line causes the change. Breakpoints are used to inspect specific logic; watchpoints are used to track down when and where a variable gets corrupted.

3 What is the difference between MESSAGE types A, E, W, I, S, X?

A = Abend (terminates transaction with dump), E = Error (shows error, stops processing), W = Warning (shows warning, continues), I = Information (popup, continues), S = Success (status bar message, continues), X = Exit (terminates silently with a dump). In most cases, A and X both terminate but differ in messaging.

4 What is exception handling in ABAP?

Exception handling in ABAP is the process of detecting and responding to runtime errors gracefully instead of letting the program crash. ABAP supports two approaches: classic exceptions using EXCEPTIONS parameters with sy-subrc checks, and class-based exceptions using TRY/CATCH blocks with exception classes derived from CX_ROOT.

5 What is the difference between TRY/CATCH and EXCEPTIONS?

TRY/CATCH is the modern, object-oriented way to handle exceptions using exception classes. EXCEPTIONS is the older method used with function modules where you list possible exceptions and check sy-subrc after the call. TRY/CATCH is preferred in new code, while EXCEPTIONS still appears in legacy function module calls.

6 How do you debug a background job?

You cannot set breakpoints in a background job because there is no user session. Instead, you use transaction SM37 to schedule the job, then use the Job → Debug option to attach the ABAP Debugger. You enter your username when prompted and release the job. When the job starts, the debugger opens automatically. Alternatively, use WAIT UP TO statements to create debugging windows, or configure Remote Debugging for RFC/HTTP calls.

7 What is ST05 and when do you use it?

ST05 is the SAP Performance Trace tool. It records all database calls (SELECT, INSERT, UPDATE, DELETE), RFC calls, and buffer accesses made by a program. You use ST05 to identify slow or excessive database queries and to measure overall program performance.

8 What is SAT and what does it measure?

SAT is the ABAP Runtime Analysis tool. It measures execution time of your ABAP code at the statement level — showing exactly which methods, function modules, and statements take the most time. Use SAT to find performance bottlenecks in your own code, while ST05 is used to analyze database access time.

🛠 Practice Task for This Chapter

Build a report that intentionally fails, then debug it. This exercise teaches you more about debugging than any tutorial.

  1. Create a program Z_DEBUG_PRACTICE that selects rows from SCARR into an internal table.
  2. Add a loop that divides 100 by each row number. Make it fail deliberately by making one of the numbers zero.
  3. Wrap the loop in TRY / CATCH cx_sy_zerodivide and display a graceful error message.
  4. Run the report. Verify the error is caught and the program does not dump.
  5. Now comment out the TRY/CATCH and run again. You will see the dump screen.
  6. Go to ST22 and read the dump. Identify the exact line where the error occurred.
  7. Set a breakpoint on that line and re-run with the debugger. Inspect the divisor value when it becomes zero.
  8. Set a watchpoint on the divisor variable. Observe the debugger pausing exactly when it changes to zero.
Why this matters In real projects, you will spend 60-70% of your time debugging. The ability to calmly open the debugger, set a watchpoint, and find the exact line that caused the issue is the single most valuable skill you can develop.
🎯 Chapter 11 Challenge

Test: Kon Banega Crorepati?

5 questions. ₹1 Crore. Prove you understood Debugging & Error Handling. No pressure — restart anytime.

₹1,000 ₹10,000 ₹1,00,000 ₹10,00,000 ₹1 Crore
Question 1 of 5
Score: 0
Q1
🏆
You Did It!
0/5Correct Answers
You won ₹0
➡️ Next Chapter

➡️ Next Chapter

You can now debug and handle errors. In Chapter 12, you will learn Enhancements — how to modify standard SAP behavior without breaking it. This is a critical skill in every real project.

Chapter 12 Enhancements — Modifying Standard SAP →
Want to Learn Faster?

Explore Our Instructor-Led SAP & IT Courses

Self-study works. But if you want guided training, real project practice, and placement support — here are the courses we offer. Book a free demo before you decide.

WhatsApp WhatsApp us
Call Now Button