Skip to Content

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

To report this post you need to login first.

14 Comments

You must be Logged on to comment or reply to a post.

    1. Jerry Wang 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

      (0) 
      1. Suhas Saha

        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

        (0) 
  1. 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…

    (0) 
  2. Vinay Mutt

    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

    (0) 
  3. 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

    (0) 
    1. Jerry Wang 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

      (0) 

Leave a Reply