Skip to Content
Author's profile photo Jerry Wang

Three ways to achieve conditional break point in your ABAP program

Let’s use the simple program below.

Line 15 will be executed 1000 times. And we are only interested with a given iteration, for example we want to ONLY stop at line 15 with condition <data> = 22.

/wp-content/uploads/2016/05/clipboard1_961581.png

Approach1 – Source code breakpoint in ABAP debugger

Create a new breakpoint in debugger dynamically:

/wp-content/uploads/2016/05/clipboard1_961581.png

Maintain your condition as below:

/wp-content/uploads/2016/05/clipboard2_961610.png

And then you should see this new conditional break point set in line 15:

/wp-content/uploads/2016/05/clipboard3_961611.png

Then F8 to continue, the break point is triggered only once when <data> = 22.

/wp-content/uploads/2016/05/clipboard4_961612.png

Approach2 – Watchpoint

/wp-content/uploads/2016/05/clipboard5_961616.png

/wp-content/uploads/2016/05/clipboard6_961617.png

You should see your created watch point here:

/wp-content/uploads/2016/05/clipboard7_961618.png

Execute program, watch point is triggered:

/wp-content/uploads/2016/05/clipboard8_961622.png

/wp-content/uploads/2016/05/clipboard9_961623.png

Approach3 – ABAP debugger script

Create a new debugger script:

/wp-content/uploads/2016/05/clipboard1_961581.png

Click “Script Wizard”->”Variable Value(for Simple Variable)”:

/wp-content/uploads/2016/05/clipboard2_961610.png

The wizard will generate code automatically for you ( marked with red ). You can finish the left code to achieve conditional break( marked with blank ). Save your script with a name.

/wp-content/uploads/2016/05/clipboard3_961611.png

Now launch your program, load the saved Script:

/wp-content/uploads/2016/05/clipboard4_961612.png

Then click Start Script:

/wp-content/uploads/2016/05/clipboard5_961616.png

Break point is triggered only once:

/wp-content/uploads/2016/05/clipboard6_961617.png

Assigned Tags

      16 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      nice information...

      Author's profile photo Former Member
      Former Member

      You could also set a "static" BP @15 and use the "Skip" option to jump directly to the 22nd row 🙂

      Author's profile photo Jerry Wang
      Jerry Wang
      Blog Post Author

      Hello Suhas,

      Thanks a lot for your comment. Yes that's also a simple but efficient solution 🙂 What I tried to demonstrate is a more generic approach. Suppose a use case if I would only like to make the loop on a string table stop at a certain condition like <DATA> = 'Jerry', then it is not easy to achieve it via SKIP option. Of course we can still manually find the index of row which contains 'Jerry' and then set this index as SKIP option. Anyway SKIP option is still another good alternative.

      Best regards,

      Jerry

      Author's profile photo Former Member
      Former Member

      Hi Jerry,

      I just wanted to give an alternative and not contest the usefulness of your option(s) 😎

      Skip only makes sense if you know the index of the iteration. Tbh, I have rarely used it and rely on watchpoints (which of course don't work with FIELD-SYMBOLS 😐 ).

      But this is kind of inconsistent that one can use field-symbols for defining the "Free Condition Entry" in Approach 1 & not in Approach 2!

      BR,

      Suhas

      Author's profile photo Jerry Wang
      Jerry Wang
      Blog Post Author

      Hello Suhas,

      Thanks a lot for your useful complement. 🙂

      Best regards,

      Jerry

      Author's profile photo ananthachari enjarapu
      ananthachari enjarapu

      tq

      Author's profile photo Suresh M
      Suresh M

      Thanks for sharing the valuable info...

      Author's profile photo abilash n
      abilash n

      Thanks for showing by ABAP Debugger Script.

      You are one of the most active participant in creating blogs in SCN. Really need to appreciate you on this...

      Author's profile photo Gokulakumar Kamalanathan
      Gokulakumar Kamalanathan

      Nice!!! Thank you for sharing 🙂

      Author's profile photo Former Member
      Former Member

      Hi Jerry, Its a very good document.

      But in the second option of watch point if there are multiple loops in that include, I believe the breakpoint will stop for all the loops rather than the intended one. The other two options are good. Will try the script one.

      Regards,

      Vinay Mutt

      Author's profile photo Thanga Prakash Thanga Raj
      Thanga Prakash Thanga Raj

      Informative 🙂

      Author's profile photo Marc Vincent Eugenio
      Marc Vincent Eugenio

      Thanks for the idea!

      Author's profile photo Joachim Rees
      Joachim Rees

      Very nice blog, thank you a lot!

      I like that you gave an easy-enough example on how to use debugger scripting - I have not tried it out yet, but believe it's a really powerful tool, so next time I need a conditional breakpoint, I'll probably use that!

      Btw:

      There's another way and I think there are not too few ("old" 😉 )  ABAPers that would just use that:

      if <data> = 22.

      break-point.

      endif.

      best

      Joachim

      Author's profile photo Jerry Wang
      Jerry Wang
      Blog Post Author

      Hello Joachim,

      Thanks for your comment. Yes, your suggestion is also a solution, simple but effective, as long as we have the full ownership of the code to be debugged, usually in our dev system. If we have to debug in customer's test or productive system, we cannot change source code that way 🙂

      Best regards,

      Jerry

      Author's profile photo Kampol Tonsakul
      Kampol Tonsakul

      good infor for new abaper.

      Author's profile photo Lakshminarasimhan Narasimhamurthy
      Lakshminarasimhan Narasimhamurthy

      Nice one, especially with script