Debugging in SAP ABAP Programming

Debugging techniques in SAP ABAP programming, working with debugging controls in SAP ABAP debugging

+ -

Debugging is one of the important part in trouble shooting of an ABAP application, we can debug ABAP code by using breakpoints.

In SAP Programming there are two kinds of breakpoints.

Static Breakpoints: These can be set by using statement BREAK-POINT in ABAP code, these breakpoints are not user specific, these will trigger for every user. We need to delete these breakpoints manually.

Dynamic Breakpoints: These breakpoints are user specific, these will trigger for specific user only. These breakpoints will be deleted automatically when you log-off from SAP. These can be set in ABAP editor. Dynamic breakpoints can be set in active (activated) source code only.

Dynamic breakpoints are of two types. External break-point: These is a type of break-point, which will get activated even for Non SAP Applications, these breakpoints will be triggered from SAP or from Non-SAP example from portal screen.

Set it through Utilities - Setting - breakpoints.

Session break-point: This break-point will be activated for call only within SAP system and its active till the User session is on.

E.g. SE38

These breakpoints have different behaviors in different types of coding blocks ex: Function Modules, Sub-routines etc.

In this lesson we will discuss the behavior of breakpoints in each.

When we put break-point in some ABAP code, control will stop at the specific place when executing the ABAP program, then it is debugging mode. We can control debugging using function keys F5, F6, F7 and F8 or using toolbar buttons in debugging screen.

1. Working with static break point.

Go to SE38, create a program ZSAPN_DEBUGGING, add below code and activate.
REPORT ZSAPN_DEBUGGING.

SKIP.

BREAK-POINT. "Static break-point
Save, activate and execute the program.

2. Working with Dynamic Breakpoint.

Go to SE38, create a program ZSAPN_DEBUG, and add below code
REPORT ZSAPN_DEBUG.

DATA : IT_MARA TYPE TABLE OF MARA,
       WA_MARA TYPE MARA.

PARAMETERS: P_MTART TYPE MARA-MTART.


SELECT * FROM MARA INTO TABLE IT_MARA UP TO 50 ROWS
  WHERE MTART = P_MTART.

LOOP AT IT_MARA INTO WA_MARA.
  WRITE:/ WA_MARA-MATNR, WA_MARA-MTART, WA_MARA-MATKL, WA_MARA-MEINS, WA_MARA-SPART.
ENDLOOP.

Go to program source code, put cursor where you wants to set break-point and click on set/delete external break-point icon (see image below).

debugging techniques in SAP ABAP

Now execute the program, provide input ex: FERT and execute (F8), breakpoint will trigger.

Now go to 'Desktop 3', which is friendly to see run-time variables and data, double click on any variable to see respected value and data in right pane.

debugging in SAP ABAP

Techniques of debugging

Now, we will learn and understand the real techniques of debugging.

What are uses of F5, F6, F7 and F8 in debugging ?

These are function keys, which are used to control debugging ex: go to next break-point, execute perform/function module which out going into it etc.

F5 - When you press F5 in debugging, you will go to next step means you program control goes to next line.

F6 - When you press F6 in debugging, it will execute the module without going into it.F6 works for performs (subroutines), Function modules, Class methods etc.

Ex for F6: we have a program, we have some function modules in the program, when we click F5 in debugging control will go into function module source code, we don`t want to go into function module, in that case we use F6, it will not go into function module instead it will execute it in one step.

F7 - When you press F7 in debugging, it will completes the current module/program in a single step.

Ex for F7: We have a program, we have a function module in the program, we have put break point, when we press F7 it will completes the program if the control is in program, when we press F7 it will complete the module( FM) when the control is in function module.

F8 - When you press F8 in debugging, control will go to next break point if any or completes the program execution.

When do we use external break-point?

Whenever we wants to debug a program, function module, Web Dynpro application or any other object from external interface (other than GUI) like portal, web dynpro etc, we need to use external break-point. We can use external break point to debug from GUI also.

Learner Questions


No Questions by learners, be first one to ask ..!!

    Please Sign in to ask a question

    Was this lesson helpful to you? Yes No 56 People out of 61 think this lesson helpful


    Lesson Navigation

    ←Previous Chapter
    Next Lesson → Classical Reports in SAP ABAP