Debug code executed in update task with infinite loop.

Debug code executed in update task with infinite loop.

Even with an external break-point, it is not always possible to trigger the debugger for update task.

The tip is to use infinite loop in your code executed in update task, to prevent the code to be debugged from execution, and then, trigger the debugger from SM50.

Infinite loop :


  " ==========================================================
  " Infinite LOOP to retrieve debug in SM50 (background tasks)
  " ----------------------------------------------------------
  DATA lw_x TYPE char1.
  IF sy-uname = 'USERNAME'. " <== Not not lock everybody
    WHILE lw_x IS INITIAL.
    ENDWHILE.
  ENDIF.
  " ==========================================================


 

SM50

Execute your code, then launch SM50, (you may have to choose your server if several are available).

You should see your program/function in the list. Select the line, In the menu : Program/session -> Program -> Debugging.

SM50

In debug mode, change the value of LW_X or use functionnality GO TO STATEMENT to exit the loop. And debug your code as usually.

About the author

fjourneau administrator

Hi, I'm Florian Journeau, SAP ABAP R3 Freelance, based in Toulouse, France. You want to know more about me, have a look on my CV : cv.fjourneau.net.

Leave a Reply