Application Development and Automation Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
joachimrees1
Active Contributor
3,903
Do you know about ABAP Debugger scripting? And if so, have you made use of it, yet?

I knew about it for quite some time already (I think it’s been around for ~10 Years), but only recently mad use of it.

This is the experience I want to share here.

The case


I had to redesign some old Z-functionality and chose the following strategy: I didn’t want to tear to much on that 15+year old coding, being afraid to accidentally kill the functionality of it. That’s why I decided to keep make a copy of it for me to boldly refactor, while keeping the original intact as a working reference. (When done, it’s a very good idea to decommission (that’s: delete) that old, then unneeded code).

So first thing I did with my copy (and that’s a good idea to always do) is: verify it indeed behaves exactly like the original. Guess what: it didn’t!

The functionality is some z-report being called from ME57, it then calling BAPI_PO_CREATE to create a purchase order (PO). The original report would create the PO, my copy would not (Message being ME155 “Requisition & & not selectable”).

Here you can make guesses on what might be the cause 🙂

Have a few guesses? Ok, let’s continue.

When copying the report and it’s includes, I got a message “enhancements will not be copied”, so I already suspected something missing.

Unfortunately there is now way if comparing to reports with each other, at least not expanding all includes and including enhancements. (Or is there? If so, please do let me know!) There’s SE39 of course, but it doesn’t do the expansion of includes…

Intermediate try: SE37 test data


Next try was, that I captured the both the calls to BAPI_PO_CREATE as SE37-test data. A very nice function:



… then I tried comparing them, as I assumed different outcome results from different input; This test data is stored in table EUFUNC but it’s not easily comparable - it could be read with FM RS_TESTDATA_GET, but then?! So I compared it manually and didn’t see any differences. An when I tested them in SE37, both cases failed. So that was a dead end. (or a hint?! 😉 )

Complete trace via Debugger Script RSTPDA_SCRIPT_STATEMENT_TRACE


So now I wanted to see where the two path’s differ. I went searching SAPCommunity for the topic and (again, as a comment of mine from 2016 proves) found https://blogs.sap.com/2010/12/14/abap-debugger-scripting-basics/ .

This taught me how to use RSTPDA_SCRIPT_STATEMENT_TRACE and that’s what I show now:

creating the trace



  1. Set a breakpoint at from where you want to start tracing. …and also one where you want to stop again. In my case it’s the call of BAPI_PO_CREATE.




Run your application and watch the debugger open on your first breakpoint.

  1. Switch to the scripting tab

  2. Now load the script RSTPDA_SCRIPT_STATEMENT_TRACE from database (ignor the button in the Popup saying “save script” ,when it should say “load”).




  1. Click “Start Script”


-> The debugger will continue to run, tracing every single line of code it comes by, until it reaches the next breakpoint.

  1. When this is the case, stop the script.



looking at the trace



  1. you can evaluate the trace directly from the debugger (in the current or a new session).


…or you can use standalone transaction SAS.

Note: it’s a lot of data, about 300.000 Lines, so it took a while to load. If that’s done, it can be downloaded to a local file:


Comparing text files with the tool of your choice.


I wanted to see the difference between the “working” and the “not working” part, so I traced them both as described above and got the tracefiles to my local machine.

Comparing two text files is easy, I used the ‘compare’-plugin to Notepad++ but your favourite tool should work as well.

The two files are well in sync, until at one point, the start to differ:



So, now that I knew I where, I only had to look up what, so I opened include MM06EFBA_BAT_AUFBAUEN and navigate to line 38 (in AdT with ctrl+l, in SE80 with ctrl+o) and there we have our explanation:
if sy-cprog ne ...



So, this is how I gained insight and answers using ABAP Debugger Scripting.

What are your use cases? And do you even still use the ABAP Standard Debugger, or are you hooked on the AdT debugger already?

As always, your input is most welcome!

Best
Joachim
8 Comments
rajesh_paruchuru
Active Participant

Hi Joachim

perhaps, as an alternative, we can possibly consider the program flow analysis as explained here

https://blogs.sap.com/2011/01/18/next-generation-abap-runtime-analysis-sat-how-to-analyze-program-fl...

and it may be worthwhile to explore the ‘Compare Call Hierarchies’ option if manual comparison of

‘Call Hierarchy’ /’Processing Blocks’ from the actual trace is tedious, i haven’t tried this myself though.

 

Thank you

-Rajesh

mmcisme1
Active Contributor
A nice new to me - way of doing things.  I seem to use trace as a backup for my ABAP debugging.  Script would probably give me less rows to look at?

I'm going to have to give this a try.   Time, if only I had more of it.

But if it works nicely, it would give me more time.  🙂

Nice to see you back and blogging!

Michelle
joachimrees1
Active Contributor
0 Kudos
Nice blog aboout how you used ABAP debugger scripting to get a full trace and find a difference in the program flow! Thanks Joachim!
MarcoK
Participant

@joachimrees1I just stumbled across this nice blog post, thanks for it. But to me it looks a bit odd that you commented on your own blog post with "... Thanks Joachim!". 😉

joachimrees1
Active Contributor
0 Kudos

Hey Marko, @MarcoK thanks for your kind feedback!

I do agree that this - commenting one owns blog / "patting my own shoulder" - seem a litte strange.

But indeed, it's something I do:
1. If it was a good read, be it helpful or entertaining, I will say so (even if it was "past me" that wrote it).
2. Those comments might help me to find usefull content again (by going through my profiel and see the list of comments). Would be sad to miss out my own blogs that way.

Best
Joachim

joachimrees1
Active Contributor
0 Kudos

Again, in 2025: A nice blog on how to use ABAP Debugger Script RSTPDA_SCRIPT_STATEMENT_TRACE , to spot the difference in seemingly different data flows! Thanks Joachim! 🙂

deepak_h3
Participant
0 Kudos

Is there a detailed blog on debug scripting. I have tried to use it but found it very complex to use.

MarcoK
Participant
Labels in this area