News in ABAP Debugger Breakpoints and Watchpoints , Statement Debugging
SAP NetWeaver 7.0 EHP2 brings an expanded set of breakpoint and watchpoint capabilities as well as a new higher-resolution statement debugging capability (of course in the New ABAP Debugger!).
This blog shows how to use these new features:
- The new types of breakpoint (on ABAP command, on Web Dynpro entities, on method of a class, on Simple Transformations…)
- The new types of watchpoints (on internal table, on ABAP objects and object attributes…)
- The new conditional breakpoints and watchpoints
This blog also explains the new statement debugging in ABAP – how you can separately debug multiple ABAP statements or expressions in one line.
If you are interested in a live demonstration of the new features in ABAP breakpoints and watchpoints, just take a look at this short video:
1. New Breakpoint Types
If you are in the New ABAP Debugger and press the Breakpoint button, you will find a whole series of new tabs in the breakpoint popup. Each of these tabs introduces a special new breakpoint type, which you can choose accordingly to your special needs, when setting a breakpoint in your code. Let’s take a closer look at some of them.
ABAP Command Breakpoints
With the ABAP Cmnds tab, you can set a breakpoint on any of a variety of ABAP statements, shown to you in the F4 Help. The possibilities include setting a breakpoint at CALL FUNCTION, CALL FUNCTION DESTINATION, CALL FUNCTION IN REMOTE TASK, CALL FUNCTION IN UPDATE TASK, …. Many people didn’t know that there are also different DELETE variants: DELETE ITAB (delete from an internal table) is different from DELETE DBTAB (delete from a database table).
Method Breakpoints
With the Method tab, you can set a breakpoint at the invocation of a method of a class.
Simple Transformation and Web Dynpro Breakpoints
On the ST Template tab, you can set a row breakpoint at the call to a Simple Transformation template.
With the Web Dynpro tab you can set a breakpoint on Web Dynpro entities. When entering components, controllers and methods, the name of the generated class is determined and the breakpoint is set there. You can also tell the debugger to stop at each ABAP stack and screen change (Misc tab) or set a breakpoint on a message (Message tab).
2. Conditional Breakpoints
Imagine you need to debug an ABAP application in which an internal table is gradually filled with a large number of data records. Somewhere during the execution an error takes place and an incorrect data record gets inserted into the table. To analyze this behavior you can tell the debugger to stop as soon as this incorrect data record gets inserted into the table. You can do this by setting a breakpoint and adding a condition to it.
To add a condition to a breakpoint, click on your breakpoint with a right mouse button and choose Create Condition from the context menu. An additional popup is displayed, in which you can enter the test condition. You can use variables in the condition, as well as debugger symbols and functions. Use the F1 Help on the Breakpoint Condition popup to see the possible condition operands and syntax.
3. New Features in Watchpoints
Now it is possible to set a watchpoint for an internal table (this wasn’t possible in the classic debugger). Just press Watchpoint button and enter the internal table name in the Create Watchpoint popup. The debugger stops when the internal table is changed. You can further refine the watchpoint by specifying a condition (for example stop only if internal table contains more then 200 rows). Enter a condition in the Free Condition Entry field. Use the F1 help to learn which functions you can use in your conditions. The debugger will stop only if the internal table has changed and your specified condition is fulfilled.
In addition, the Break./Watchpoints tab shows which watchpoint has a hit, and you can for example view and compare a variables in its current (after stopping at a watchpoint) and previous state.
A further new feature is the ability to set watchpoints on objects. Just enter the object name in the Create Watchpoint popup. In this way you can monitor the object during execution of your program. The debugger will stop as soon as the object changes. You can also set a watchpoint at object attribute (choose Watchpoint at Object Attribute radio button) and select any desired types of instance and static attributes. The debugger then stops if an attribute has changed. Afterwards you can take a look at this attribute change on the Break./Watchpoints tab by selecting your watchpoint there and clicking on its details magnifier (in our example the ‘Expander’ attribute has changed from ‘X’ to a ‘space’).
4. Statement Debugging
Now imagine you are stepping through your code in the debugger and execute a long IF… statement, consisting of many different subcondtions. You expect a positive result, but unfortunately the IF… statement delivers you the negative answer. To analyze this behavior you need to understand which subcondition of this long IF…statement failed.
You can easily evaluate the conditions in the IF by changing the step size in the debugger. By pressing the Step Size button you activate the statement debugging, and the debugger will execute the subconditions of for example your long IF… statement separately one after another. You can then analyze return values of single subconditions on the Auto tab of the variable fast display window. By pressing the Step Size button again you return to a normal line stepping in the debugger.
thanks for keeping us up to the with the newest development in new debugger area. Do be honest I do not think that new debugger even on releases like 7.0 is matured enough. E.g. I encountering a bug while trying to search for values in internal table. Simply search doesn't work 🙂
Anyway I try to find a way I would I report this to SAP officially.
Rgds, Martin
I see that we have finally the list of possible ABAP commands, could someone be gentle enough to paste the list from EHP2 so that we can use them in older releases (I just discovered thanks to Olga that on my 7.0 system, "INSERT ITAB" allows to stop at each insert on itab, and "INSERT DBTAB" is for database, there are "MODIFY DBTAB", "DELETE ITAB", etc. nice! but not "DELETE DBTAB" by the way...)
Thank you community for your help! 🙂
Sandra
the feature of linking the watch points with 'AND' condition...(classical debugger has this capability)is this already supported? and I thought the watch point on an internal table was already introduced in previous releases.
-Rajesh.
you can define free conditions for watchpoints in the "Free Condition Entry" field (see the blog part about watchpoints for a picture).
Best regards,
Olga.
yes, the standard limitations for the maximum number of open sessions per user (6 sessions) are still valid. The new debugger requires always its own session.
Best regards,
Olga.
BTW, I'll ask in the forum if someone can paste the possible names for "breakpoint at".
Sandra
I still see the same message while trying to debug screens.
Thanks,
Aditya
yes, you can set a breakpoint for screen debugging on the "Srce Code" tab in the "Screen" section (enter screen number, line).
Regards,
Olga.
Regards,
Madhu.
from application perspective, you need to apply EHP5 (Business Suite Innovations 2010). EHP5 is technically based on SAP NetWeaver 7.0 EhP2.
Best Regards,
Olga.
Thank you. So i can not see these features in EHP4.
Regards,
Madhu.
I am also waiting for "Debug as you code" functionality...Any updates when this will be introduced?
Thanks,
Regards,
Mohaiyuddin
do you mean the capability to change your source code on the fly in the editor while you are debugging and and let debugger automatically debug the changed code? If it is so, then this capability is not planned.
Best Regards,
Olga.
I am talking about same functionality..I was hearing from some time that this would be available in future.
Thanks,
Regards,
Mohaiyuddin
Cheers,
Yellappa.
you can upload data into internal tables in the debugger with NetWeaver 7.0 EHP2. It is available for all customers.
You may want to check the NetWeaver 7.0 EHP2 Trial Version, which is available on the SDN ABAP page for free download:
http://www.sdn.sap.com/irj/sdn/abap?rid=/library/uuid/80db43c2-9ee5-2d10-de8e-8547de363868
Best regards,
Olga.
thanks for this interesting news which i really would like to use. We use a SAP Netweaver 7.02 EhP4 but i can't see all the TABs you describe. Do i have to activate them or do you know the reason why i can't see them?
Thanks for any help
Günter
you need to apply Business Suite Innovations 2010 EHP5. If you use Business Suite EHP4 you will not be able to see these fetaures. Only EHP5 is based on NetWeaver 7.0 EhP2.
Best Regards,
Olga.
Is there a way currently to set a watchpoint when the value in a single field within an internal table is changed?
Frequently, I'll be debugging a sales order and want to know when XVBAP[6]-NETWR is changed, but the debugger doesn't permit this?
It let's me watchpoint the entire internal table XVBAP[] but not a specific value?
yes, you can set a watchpoint only on the entire internal table.
Best regards,
Olga.
Hi,
This is a very useful post. Thanks for it.
It seems that there were some major improvements in the debugging area.
I think that there is one useful feature that is still missing: It would have been nice to be able to create watchpoints for internal tables with a free condition for the last added record: Many times we need to track after addition of specific record (according specific criteria). As described in your video demonstration, currently this can be done, but it is little more complicated as you first need to analyze the whole internal table, afterwards use the lines() option in the free condition and then restart the program.
Please consider it in future releases.
Best regards,
Shai
Hi Olga,
Excellent article.
However, I want to know if its somehow possible to put a watchpoint on STATICS variables. In one of my codes, I am noticing that the value of a static variable (in an FM which is called inside a loop ) is getting changed to an unpredicted value for a particular record. For rest of the records, its working fine.
I tried putting a WP on it but its not stopping anywhere and the value is still getting changed.
Could you please suggest me anything in this regard ?
Thanks & Regards,
Sapeksh
Hello Olga,
Thanks for explaining in such a beautiful way. I tried the Step-size thing which you have shared,but didn't work out. Can you please provide more simpler ways of understanding of step-size with an example.
Thanks
Sumit
Hi Sumit,
this ABAP debugger feature is very simple. Just write an ABAP program with a simple IF statement of your choice with some sub-conditions. Start the debugger, press the "Step size" button and step through your program with the debugger single step (F5). Each sub-condition will be executed separately. Without pressing the "Step size" button the whole IF will be executed at one step.
Regards,
Olga.
Hi Olga,
As suggested by you I have written a piece of code
DATA : A type i VALUE '1',
B type i VALUE '2',
C type i VALUE '3',
D type i VALUE '9'.
IF ( D GT 5 OR A LT 4 ) AND ( C LE 3 OR B GT 2 ).
write:/03 'Successful'.
ENDIF.
Whenever at Debugger mode i am pressing the "Step-Size" and then F5 then I am not able to see the results in Auto Tab. I don't know whether I am doing wrong or in the code. Please help!!!
Thanks & Regards
Sumit
Hi Sumit,
with this program you should be able to execute each subcondition separately in the debugger and see that statement debugging works. You see nothing in the Auto tab, because it displays only the last return values of methods. If you use methods in subconditions (as in my example above) you will see every return value in the Auto tab.
Regards,
Olga.
Hello Olga,
Thanks you for the advise. As suggested by you it was working fine. But one more thing i observed is even without pressing the Step-size ,values of the methods are appearing in Auto Tab and with pressing the Step-size it appears.If it is so then what does Step-size button does.
Correct me if i am wrong.
Thanks & Regards
sumit
Hi Sumit,
Step-size button and Auto tab are two different things. Step-size is for statement debugging and Auto tab for displaying return values of methods. If you have methods as sub-conditions within statement debugging, then you can see their return values on the Auto tab.
Regards,
Olga.
Hello Olga,
Thanks for the reply. I got the Step-size and Auto tab clearly. Can we use Step-size in other scenarios without using methods, So that we can get the clear understanding of Step-size.
Thanks & Regards
Sumit
Hi Sumit,
please read again the chapter 4 “statement debugging” carefully. Step-size button activates statement debugging. It has nothing do with methods. You can use methods in subconditions or not: it is up to you.
Regards,
Olga.