Skip to Content
Author's profile photo Ladislav Rydzyk

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.

Enjoy πŸ˜‰

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Alessandro Spadoni
      Alessandro Spadoni

      I saw many times this method....calling a function module with ZDO_ENDDO inside and then SM50..

      to debug a job check this thread

      to debug an RFC check external breakpoints πŸ™‚

      Author's profile photo Former Member
      Former Member

      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,

      Ram Ganji

      Author's profile photo Custodio de Oliveira
      Custodio de Oliveira

      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. 😎