How to debug the FM which is called in background task
James Zeng Date: 2012-06-28
Today I met one issue that there is one FM-AAA which be called in program BBB in background task way, now we want to debug the FM-AAA.
The real FM-AAA is ZVXX_IDOC_ASNPP, the caller program is IDOCS_OUTPUT_TO_OWN_FUNCTION for my real case.
When the program really run, the EDIPOF-FUNCTION will be replaced with ZVXX_IDOC_ASNPP in my situation.
- Set external breakpoint in the FM-AAA (ZVXX_IDOC_ASNPP)
- Start program-BBB (IDOCS_OUTPUT_TO_OWN_FUNCTION) in debug.
- When you reach the breakpoint, select menu Settings, Display/Change debugger settings, select the flag “tRFC (In Background Task): Block Sending”. This flag means that, when the commit work occurs, the background task (FMs + parameters) is stored into database but not executed.
- Run the t-code SM58
- Select the background task you just created, and choose menu edit + debug LUW, the “background task” will start interactively and the debugger will stop at predefined points by in FM AAA automatically.
My demo example:
We use one shipment to trigger one output type ZASN to call FM-IDOC_OUTPUT_SHPMNT to create the shipment IDoc, then based on this shipment IDoc to create the customer ASN IDOC( which will call FM- ZVXX_IDOC_ASNPP )
After the ‘commit work’ statement called, the background task created in the database
Then use SM58 to search whether any background task created
We debug this background task
Then the logic will stop at the breakpoint we set in the FM- ZVXX_IDOC_ASNPP.