How to debug program in background?
There might be a problem when you need to debug such a program, because you never know, when your code will be called.
Here is the simple trick:
DATA: lv_counter TYPE i.
* Call neverending loop in your code
WHILE lv_counter = 0.
“this will stop, when you change lv_counter
“to s/thing else in debugger
And run your program.
Go to transaction “SM50” find your running program in a process. Select the process -> click Program/Session -> Program -> Debugging. In debug mode, just change the value of lv_counter to something else and now, you are able to debug your dynamically called program in background.
I saw many times this method....calling a function module with ZDO_ENDDO inside and then SM50..
to debug a job check this thread http://scn.sap.com/thread/3186288
to debug an RFC check external breakpoints 🙂
In SM37: Select the job, type JDBG in the OK-code and press enter. This can be used for both completed jobs and jobs to be processed (just make sure you have enough time to debug before the job actually starts). Breakpoints set in the job flow works.
Thanks & Regards,
I first saw the WHILE...ENDWHILE aproach in 2000, and it was suggested by SAP 🙂
Although the JDBG is the preffered option I still think WHILE "technique" is valid in some situations and I am not ashamed of using it. 😎