天天看點

How to achieve conditional break point in your ABAP programApproach2 - WatchpointApproach3 - ABAP debugger script

有不同的同僚問我這個問題:例如LOOP要執行1000次,我隻對其中的某一次比如第501次循環感興趣,我肯定不可能按500次F5.或者我隻對 LOOP裡某個變量為某一個具體值的那一次循環感興趣。如果避免重複按F5, 而是讓斷點直接停在我想停的condition上面?

How to achieve conditional break point in your ABAP programApproach2 - WatchpointApproach3 - ABAP debugger script

其實有三種方法實作。

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 = 22.

How to achieve conditional break point in your ABAP programApproach2 - WatchpointApproach3 - ABAP debugger script
Maintain your condition as below:
How to achieve conditional break point in your ABAP programApproach2 - WatchpointApproach3 - ABAP debugger script
Then F8 to continue, the break point is triggered only once when = 22.
How to achieve conditional break point in your ABAP programApproach2 - WatchpointApproach3 - ABAP debugger script

Approach2 - Watchpoint

How to achieve conditional break point in your ABAP programApproach2 - WatchpointApproach3 - ABAP debugger script
How to achieve conditional break point in your ABAP programApproach2 - WatchpointApproach3 - ABAP debugger script

Then:

How to achieve conditional break point in your ABAP programApproach2 - WatchpointApproach3 - ABAP debugger script

Approach3 - ABAP debugger script

Create a new debugger script:

How to achieve conditional break point in your ABAP programApproach2 - WatchpointApproach3 - ABAP debugger script

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

How to achieve conditional break point in your ABAP programApproach2 - WatchpointApproach3 - ABAP debugger script

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.

How to achieve conditional break point in your ABAP programApproach2 - WatchpointApproach3 - ABAP debugger script

Now launch your program, load the saved Script:

How to achieve conditional break point in your ABAP programApproach2 - WatchpointApproach3 - ABAP debugger script

Then click Start Script:

How to achieve conditional break point in your ABAP programApproach2 - WatchpointApproach3 - ABAP debugger script

Break point is triggered only once:

How to achieve conditional break point in your ABAP programApproach2 - WatchpointApproach3 - ABAP debugger script

繼續閱讀