Thursday, 21 August 2014

Infinite Loop for background debugging

I use this all the time for debugging SAP ABAP "background" operations. Sometimes you can't debug straight to a bit of code, as it's operated on by the server, not the a frontend session.
So, what I do, is use this simple bit of code:

 data: a, b.
 a = 'X'.
 do.
   if a = b.
     exit.
   endif.
 enddo.

Which, as you can probably tell, sets the program into an infinite loop, which can only be interrupted by debugging.

This is done in transaction SM51 - find the session with ( your / system ) name on it, and hit Program-Debug from the menu


At this point, you can then clear out the "a" variable, which then means that a = b, and so the loop gets exited. You can then debug through the background process.

There are other ways of doing it, but I've found this one to be the simplest and most reliable.

Don't forget to take it out again once you're finished, otherwise you'll paralyse the backend!

1 comment: