Sap Abap On Hana-1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

SAP ABAP on HANA

Debugging Techniques in SAP ABAP


*************************************************
Debugging Techniques in SAP ABAP
Milan Victor – SAP
MILLU138@GMAIL.COM
ABAP/Webdynpro/CDS/ODATA/SAP UI5/FIORI

Purpose of this document:


This document will detail the process of debugging in SAP ABAP programming.

What is Debugging?
Debugging entails analyzing a program's flow to identify and rectify defects or bugs. SAP
distinguishes itself from other programming languages by involving the analysis of various
objects during the debugging process. Consequently, diverse techniques are employed for
debugging different object types.

Why do we need a Debug:


In the SAP environment, debugging is facilitated through the ABAP Debugger, a programming
tool capable of scrutinizing an ABAP program or object on a line-by-line or section basis. It also
allows for the dynamic alteration of object values during runtime.
There exist two varieties of SAP ABAP Debuggers: The Classical Debugger, applicable to releases
up to 6.40, and the New ABAP Debugger, designed for all releases from 6.40 onwards.

Advantages of Debugging:
1) Pinpointing the exact cause of an issue
2) Efficient use of resources
3) Enhanced program logic
4) Improved code quality
5) Better collaboration among teams
6)
Types of Debugging techniques:
1) Classic Debugging
2) New ABAP Debugger

Classical Debugger:
The predominant debugging method in SAP ABAP is the classic debugging technique, widely
employed by developers. This approach includes the placement of breakpoints within the code,
which halts program execution. This interruption provides developers with the opportunity to
scrutinize the values of variables, tables, and other data objects.

New ABAP Debugger:


The New ABAP Debugger represents an upgraded iteration of the traditional debugger in SAP
ABAP, incorporating supplementary features and enhanced functionality for program
debugging. Notable aspects of the new debugger encompass the ability to debug multiple
sessions concurrently, conduct code coverage analysis, perform code profiling, and benefit from
an improved user interface, among others.

https://www.linkedin.com/in/milan-victor-xavier-1713b3192
Milan Victor – SAP
MILLU138@GMAIL.COM
ABAP/Webdynpro/CDS/ODATA/SAP UI5/FIORI

Difference between Session and external breakpoints:


Session Breakpoint:
Set within the ABAP program code, affecting only the user's session. When the program
execution reaches the line of code where the session breakpoint is set, it interrupts the
execution, allowing the programmer to analyze and debug the program at that point.

External Breakpoint
Set outside the program code, often in the ABAP Editor or Debugger, with a broader
scope that can affect multiple users working on the same program.

How to Set the session breakpoint:


Step1: Open the Program in SE38

Step2: Set the breakpoint


 We can click over the line and set the breakpoint

https://www.linkedin.com/in/milan-victor-xavier-1713b3192
Milan Victor – SAP
MILLU138@GMAIL.COM
ABAP/Webdynpro/CDS/ODATA/SAP UI5/FIORI

 Place the cursor over the line and press the session breakpoint button.

How to set the user ID for this external breakpoint.

UtilitiesSettingABAP EditorDebuggingUser ID

https://www.linkedin.com/in/milan-victor-xavier-1713b3192
Milan Victor – SAP
MILLU138@GMAIL.COM
ABAP/Webdynpro/CDS/ODATA/SAP UI5/FIORI

How to debug based on the message, Function module, class, method, etc.
Step1: Find the message class and message number from the error message

https://www.linkedin.com/in/milan-victor-xavier-1713b3192
Milan Victor – SAP
MILLU138@GMAIL.COM
ABAP/Webdynpro/CDS/ODATA/SAP UI5/FIORI

Click over the error message and that will open the one window where we can see the message number
and class.

Message Number: FR180


Message Class: FR
Message Number: 180
Step2: Put a dynamic breakpoint
Execute the tcode, put /H into the comment box and press enter.

Then press the execute button. After that dynamic breakpoint will be triggered.

https://www.linkedin.com/in/milan-victor-xavier-1713b3192
Milan Victor – SAP
MILLU138@GMAIL.COM
ABAP/Webdynpro/CDS/ODATA/SAP UI5/FIORI

Step3: Set the breakpoint at the message:


BreakpointBreakpoint atBreakpoint at message

Here we can see all possible ways to set the breakpoints. But here we are going to use breakpoint at
message option.

https://www.linkedin.com/in/milan-victor-xavier-1713b3192
Milan Victor – SAP
MILLU138@GMAIL.COM
ABAP/Webdynpro/CDS/ODATA/SAP UI5/FIORI

Next, give the Message ID and Number in the correct fields and click the ok button to set the breakpoint
based on the message ID and number.

Then, u will see the message like this,

Then Press F8 to navigate the exact place for the error,

Next cursor will stop to the exact place,

These are the steps to set the breakpoint based on the message, like the same we can set it for Function
module, class methods, perform, etc.

https://www.linkedin.com/in/milan-victor-xavier-1713b3192
Milan Victor – SAP
MILLU138@GMAIL.COM
ABAP/Webdynpro/CDS/ODATA/SAP UI5/FIORI

Watch Points:
Watchpoints are breakpoints with a specific purpose – monitoring the values of variables or expressions
at runtime. While traditional breakpoints pause program execution to allow you to inspect the code,
watchpoints take it a step further by actively tracking the changes in variable values. This can be
immensely helpful in locating the source of a bug or understanding the flow of your program.
Benefits of Watchpoints:
 Dynamic Monitoring
 Reduced Breakpoints
 Efficient Issue Identification
 Enhanced Debugging Experience
How to set the Watchpoint:
Step1: Put the session or external breakpoint in the program

Step2: Give the Inputs and execute the Tcode:

Step3: Set the watchpoint


Click Create Watchpoint button to create the watchpoint

https://www.linkedin.com/in/milan-victor-xavier-1713b3192
Milan Victor – SAP
MILLU138@GMAIL.COM
ABAP/Webdynpro/CDS/ODATA/SAP UI5/FIORI

Then, a new popup will come up like the following screenshot

Here you have to give the variable and Condition to set the watch point. I will set the watchpoint for the
currency field with a value of USD. That means if the currency field is USD means then only watchpoint
will be triggered.

After giving the variable name and condition we need to press the ‘OK’ button, then we will receive the
message below.

Then we have to press F8, whenever the currency is USD that time watchpoint will be triggered.

https://www.linkedin.com/in/milan-victor-xavier-1713b3192
Milan Victor – SAP
MILLU138@GMAIL.COM
ABAP/Webdynpro/CDS/ODATA/SAP UI5/FIORI

Best Practices for Using Breakpoints


To harness the full power of breakpoints, consider these best practices:
1) Strategic placements
Place breakpoints where they matter the most. Focus on critical decision points, loops, and
areas where you suspect issues might arise.
2) Temporary vs. permanent Breakpoints
Use temporary breakpoints during initial debugging sessions. If the issue is persistent, consider
converting them into permanent breakpoints for future reference
3) Conditional Breakpoints
Enhance your debugging efficiency by setting conditions for breakpoints. Pause execution only when
specific criteria are met, reducing unnecessary interruptions
4) Deactivation after Use
Once you've identified and resolved an issue using breakpoints, deactivate or remove them. Leaving
inactive breakpoints in your code can lead to confusion and unnecessary pauses
5) Documentation
Consider adding comments or documentation explaining the purpose of breakpoints. This can be
especially helpful when revisiting code or when collaborating with other developers

Conclusion:
Breakpoints in SAP ABAP are more than just tools for finding and fixing bugs; they are your allies in
understanding, optimizing, and mastering your code. By strategically placing breakpoints, utilizing
different types, and following best practices, you can streamline your debugging process and become a
more proficient ABAP developer.

Remember, breakpoints are not just for troubleshooting errors; they are essential for gaining deep
insights into your code's execution. So, embrace breakpoints, use them wisely, and let them guide you
through the intricate paths of SAP ABAP development. Happy coding and debugging.

https://www.linkedin.com/in/milan-victor-xavier-1713b3192

You might also like