Skip to Content
0

How to debug a function module called in background task ?

May 30, 2017 at 11:13 AM

713

avatar image

I have a custom function module, which is called in during a standard process at Work Order SAVE.
The FM is called by using statement : 'Call Function <FM name> in Background task'.

To analyze the issue, I need to go inside this FM during debugging when the process is executed. I have also tried endless loops as well, the flow is stuck there but it is not visible in transaction SM50. As a result, I am not able to debug the same, and also the Order is not getting opened in Change mode.

Is there any way of doing this ?

10 |10000 characters needed characters left characters exceeded

If you do an endless loop and you don't see the process in SM50, then it's because:

  • Either it's run by another application server. Use SM66 instead of SM50 to see workprocesses of all application servers.
  • Or you use WAIT UP TO n SECONDS which makes it disappear from the active workprocesses during this N second(s). Instead, use an empty endless loop DO ENDDO (in debug you can jump after the ENDDO).
1

Sandra,

Does that mean in this case,if it is not showing up in SM50,it will show up in SM66 ?

Do we have the option of switching into Debugging Mode by choosing the concerned workprocess in SM66,similar to what we do in SM50 ?

Thanks,

K.Kiran.

0

I said EITHER 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.

1
* Please Login or Register to Answer, Follow or Comment.

3 Answers

REM REM May 30, 2017 at 12:02 PM
2

Hi,

Turn on the "tRFC (In Background Task): Block Sending" flag in the debugger settings

Go to SM58, select the tRFC

EDIT -> debug LUW

Show 5 Share
10 |10000 characters needed characters left characters exceeded

Hi,

Thanks for the response. I have already tried the same, but it didn't work in my case.
No entry present in SM58.

Process :-
Work order is created in ECC from the CRM Web UI.
And during Update process, our scenario is executed. The custom FM is called in a BADI that is executed in update task. 'Update debugging' and 'tRFC (In Background Task)' setting also didn't help us in getting into the FM.

0

So, you need first to enter Update Debugging (debugger options). When you enter the update task, you need to make sure "tRFC block sending" is activated, then use SM58 and so on.

2

Hi Sandra,

Thanks for the suggestion. We have already tried both these settings : 'Update debugging' and 'tRFC block sending'.
But we still didn't get any entry in SM58.

Regards,
Tapas

0

Maybe there's an authorization issue or a bug in the kernel? For the first case, use SU53 ou ST01; for the second one, you should check the SAP notes, and if none fits the issue, then contact the SAP support.

0

Addendum: are you sure it's a "local" tRFC call ? Don't tell me that there's a DESTINATION defined in the CALL FUNCTION IN BACKGROUND TASK. In that case, you should check in the target system.

0
Evgeny Gubenko May 31, 2017 at 07:12 AM
-1

Hi!

You can try to put endless loop DO... ENDDO and then go to SM51 and find your process and then choose Administration->Program->Debugging

Hope it's helpful

Evgeny

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Hi Evgeny,

I have tried the endless loop, the background FM is stuck at the point. But it's not visible in SM50, as a result I am not able to debug the same.

Regards,
Tapas

0

If your system has more than one appserver, perhaps you're logged on to the wrong server. Use SM51.

0
Rob Dielemans May 30, 2017 at 03:29 PM
0

Hi,

in de abap editor go to utilities-->settings

Then tab ABAP editor-->Debugging.

Type here the user id that is used when you call the fm in background task. Now place an external break-point in the code and reproduce the behaviour.

If the user is a background user, then temporarily change it to dialog.

Kind regards, Rob Dielemans

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Hi Rob,

We have debugged the scenario by putting an external breakpoint in the code. But we are not able to drill down into the custom FM that is called in 'Background task'.

Regards,
Tapas

0

Did you try setting the external breakpoint in the custom FM that is called in 'Background task'?

0