Skip to Content
Author's profile photo Former Member

How to debug the FM which is called in background task

How to debug the FM which is called in background task

James Zeng    Date: 2012-06-28

Symptom

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.

How to debug the FM which is called in background task_01.JPG

When the program really run, the EDIPOF-FUNCTION will be replaced with ZVXX_IDOC_ASNPP in my situation.

How to debug the FM which is called in background task_02.JPG

Solution

  1. Set external breakpoint in the FM-AAA (ZVXX_IDOC_ASNPP)
  2. Start program-BBB (IDOCS_OUTPUT_TO_OWN_FUNCTION) in debug.
  3. 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.
  4. Run the t-code SM58
  5. 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 )

How to debug the FM which is called in background task_03.JPG

How to debug the FM which is called in background task_04.JPG

After the ‘commit work’ statement called, the background task created in the database

How to debug the FM which is called in background task_05.JPG

Then use SM58 to search whether any background task created

How to debug the FM which is called in background task_06.JPG

How to debug the FM which is called in background task_07.JPG

We debug this background task

How to debug the FM which is called in background task_08.JPG

Then the logic will stop at the breakpoint we set in the FM- ZVXX_IDOC_ASNPP.

How to debug the FM which is called in background task_09.JPG

Assigned Tags

      3 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Syam Babu
      Syam Babu

      Dear James,

      Nice Blog,it's very needful for developers.

      Thanks,

      Syam.

      Author's profile photo Christian Drumm
      Christian Drumm

      Hello James,

      nice blog. This was a feature of the debugger I didn't kow so far.

      However, I'm wondering why you are not simply using an external breakpoint in the FM that you want to debug. Even if the FM is called in a background task the external breakpoint works.

      Best,

      Christian

      Author's profile photo Vitor Carlessi
      Vitor Carlessi

      Thanks 🙂