Debugging in SAP ABAP

by | Apr 8, 2019 | ABAP Beginner

Home » SAP » ABAP » ABAP Beginner » Debugging in SAP ABAP

Preface – This post is part of the ABAP Beginner series.

Introduction

Whenever a SAP coder writes a program. At the time of execution, if it gives a dump or runtime error then SAP debugger is a tool to check your lines of codes and examine error during runtime. Debugging in SAP ABAP helps a programmer to check his program flow at runtime.

We use ABAP debugger by default after the release of SAP 7.0.

Definition

In short, we can define as:

  • A tool to analyze ABAP programs.
  • A tool to examine errors in codes during runtime.
  • A tool to display data objects.
  • A tool to understand the flow logic of codes in a program while executing.

Stepping through a program with the debugger helps you to detect and correct errors in the source code of an ABAP program.

What is a Breakpoint?

A signal which tells the runtime processor to interrupt processing and start debugging.

It gets activated when the program reaches that point.

How can we debug

By setting a breakpoint

Start the debugger by setting and managing the breakpoints and executing the code.

By running the program debugging mode

We can enter the debugging mode by using \h from any screen.

This can be done when we want to check the program from the beginning and are not familiar with the program.

Types of Breakpoints

There are two types of breakpoints:

A. Static Breakpoint

  1. This breakpoint is not specific to a user.
  2. To use a static breakpoint use ABAP Keyword BREAK-POINT.
  3. Place it in the line where you want to use the breakpoint.

EXAMPLE:

PROGRAMM Z_USERDATA.

…..if sy-subrc<>0 .

BREAK-POINT.

endif.

….

  1. If you want to set a static break-point specific to a user.

BREAK-POINT username.

NOTE:

Kindly delete the static breakpoints manually in development system itself, else it might affect the program in the production system.

B. DYNAMIC BREAKPOINT

  1. These are breakpoints that are triggered when the program that you are running reaches a particular ABAP statement or exception class.
  2. When debugging session is finished it gets deleted automatically.
  3. U can set a dynamic breakpoint, either in an ABAP editor or directly in the debugger.

c.1. For setting dynamic breakpoints in ABAP editor.

c.1.1  Position the cursor on the line of source code where you want to set the break-point.

c.1.2.  Go to utilities->breakpoint->Set/Stop. The system confirms that breakpoint is set.

c.2. For setting a dynamic break point in debugging mode:

c.2.1- Position the cursor on the line where you want to set the breakpoint.

c.2.2- Select the line by double -clicking it or by choosing Breakpoint-> set/delete.

NOTE:  A user can set 30 dynamic breakpoints without changing the program code.

  1. Session breakpoint
    Specific to a particular ABAP user session. If the user session is ended (log off sap system) all session breakpoints get deleted.
  2. External breakpoint
    They are applied to the current user session as well as future user sessions.

e.1. Works in sessions initiated with RFC or HTTP requests or any other external interface.

e.2. An external breakpoint can apply to:

e.2.1.A user in the current SAP system

e.2.2. A user in the current application server of the current SAP system

e.2.3. User sessions started by a request that has a specific terminal ID.

NOTE:  Session, External breakpoints can be created at runtime and can be activated/deactivated.

Special KEYS in Debugging

Debugging in SAP ABAP - Image Illustration

Debugging in SAP ABAP – Image Illustration

F5- Executes a program line by line.

F6- Executes a function module or a subroutine without entering into it.

F7- Executes a module or a program in a single step.

F8 – Executes a program directly. If there is more than one break-point, then can move to one break-point to the other.

Author

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Author