Skip to Content
Author's profile photo Former Member

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

Debugger1.PNG

2. Select breakpoint:

Debugger2.png

3. Set break point condition:

Debugger3.png

4. Continue debugging (F8):

Debugger4.png

5. This is it: debugger stops at 46-th record of the loop.

Debugger5.png

6. In case one need to stop at some specific value – at the step 3 specific condition is entered:

Debugger6.png

Small but useful debugging trick, I hope it will be helpful!

Regards,

Mario

Assigned Tags

      19 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Thangam Perumal
      Thangam Perumal

      Hi Mario,

                  Nice info...

      Regards,

          Thangam.P

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      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.

      Author's profile photo Kumar Akshat
      Kumar Akshat

      Well, there's an easier way out. You can simply specify the "Skip" number there in the same tab and achieve the same result.

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      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.

      Author's profile photo Mahadeo Kedari
      Mahadeo Kedari

      hiii,

          Very Nice.........Keep it up!!!!!!!!!!!!!!

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Ok, I agree! 🙂

      Author's profile photo Nithya M
      Nithya M

      Hi,,,

              its veryuseful one......many times i thinking about how to debugging particular record from the loop.Now cleared..its time saving also..... ➕

      Author's profile photo Former Member
      Former Member

      Simple but powerful 🙂

      Author's profile photo Former Member
      Former Member

      Mario, How does it differ from watch point?

      Author's profile photo Former Member
      Former Member

      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.

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      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

      Author's profile photo Sameena Patel
      Sameena Patel

      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

      Author's profile photo Former Member
      Former Member

      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!

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      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

      Author's profile photo Former Member
      Former Member

      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.

      Author's profile photo Former Member
      Former Member

      Really Nice one..

      Regards

      Jai

      Author's profile photo Budtawan Vu
      Budtawan Vu

      Thank you for your knowledge.

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      You're welcome,

      I'm glad it has been helpful. 🙂

      Cheers,

      Mario

      Author's profile photo Paul Karunakar
      Paul Karunakar

      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 🙂