Debugging loop
Did you ever had to step into loop looking for 46-th row or looking for occurrence of some value?
Instead of painful record by record stepping trough loop, why not use breakpoints/watchpoints?
While debugging one can do this:
1. Open up Breakpoints/Watchpoints tab
2. Select breakpoint:
3. Set break point condition:
4. Continue debugging (F8):
5. This is it: debugger stops at 46-th record of the loop.
6. In case one need to stop at some specific value – at the step 3 specific condition is entered:
Small but useful debugging trick, I hope it will be helpful!
Regards,
Mario
Hi Mario,
Nice info...
Regards,
Thangam.P
Thanks Thangam.
Those kind of tips are probably nothing new for abap expert developers but for us functional consultants who use abap occasionally, it's good to have this kind of information available in SCN.
Well, there's an easier way out. You can simply specify the "Skip" number there in the same tab and achieve the same result.
Thanks for your comment Kumar,
of course "Skip" is easier way to get to exact row in the loop but if you don't know exact sy-tabix or you want to stop at first occurrence of some value or when condition is achieved (last example picture: ls_item-wa_item-itemtype NE '0TAXITEM') you have to define condition.
From this point of view it's more useful to teach people how to use conditions.
hiii,
Very Nice.........Keep it up!!!!!!!!!!!!!!
Ok, I agree! 🙂
Hi,,,
its veryuseful one......many times i thinking about how to debugging particular record from the loop.Now cleared..its time saving also..... ➕
Simple but powerful 🙂
Mario, How does it differ from watch point?
Sy-tabix can change multiple times inside a loop due to nested loop, read statements, FM calls. Watchpoint can give false alarm.
Conditional breakpoint is more exact because it will stop at desired line number, when some additional condition is satisfied.
I checked watchpoints.
Manish is right for sy-tabix in complex conditions like nested loops, read statements etc, but I believe, same risk is possible when breakpoint has been used.
In watchpoint one can use additional/complex conditions same as in breakpoints and from that point of view it's identically useful.
Correct me if I'm wrong.
Br,
Mario
I have been using watchpoints to achieve this. For simple loops, sy-tabix works, but for complex loops I prefer adding additional condition with value check
Nice topic. instead of going to watchpoints screen in debugger as shown in the screenshots, directly right click on the debugging point and pickup conditional break point and write the same! you can write the complete condition. definitely it is useful when you have many entries in the internal table.
How it is different from watch points?
you can have multiple conditions with various operands.
it is just smaller version of script debugging and better than watch points. if you want to go advanced, you can explore script debugging where you can write code for debugging using wizard!
Thanks for valuable comment. Until now, I didn't need script debugging.
Maybe, You should consider to prepare document on topic of script debugging? 🙂
Br,
Mario
Hi Mario, I am glad that you found my comment useful. There are already many docs on script debugging. below is one specimen.
http://scn.sap.com/people/stephen.pfeiffer/blog/2010/12/14/abap-debugger-scripting-basics
Start with writing small script in the condition preferably with AND or OR statements and continue on actual script debugging 🙂
Cheers.
Really Nice one..
Regards
Jai
Thank you for your knowledge.
You're welcome,
I'm glad it has been helpful. 🙂
Cheers,
Mario
Thank you so much for this really i solved my issue very fast bec of this info even though i got 10 year of ABAP experience i dont know this exist 🙂