https://answers.sap.com/questions/211129/how-to-debug-a-function-module-called-in-backgroun.html
1.方法1
Turn on the "tRFC (In Background Task): Block Sending" flag in the debugger settings
Go to SM58, select the tRFC
EDIT -> debug LUW
2.方法2
try SM66 if you have several application servers, OR you used WAIT UP TO n SECONDS. So, I can't tell you if it will show up in SM66, especially if the issue is the other option.
The debug option is available in SM66 from Basis 7.40. If you have a previous release, then you need to check on which application server is running your endless loop via SM66, then you switch to this server via SM51, then you start SM50.
演示过程:
https://blogs.sap.com/2012/06/28/how-to-debug-the-fm-which-is-called-in-background-task/