Restrict background task usage

Scenario

If you use background tasks in parallel, you might overload the connected engine because the SAP system is sending too many requests per second. To limit how many requests are sent you can either resize the logon group /AEB/DEFAULT or implement the BAdI /AEB/01_QTSK_CTRL_01. Resizing the logon group is easier but also not as accurate because you can only specify a percentage of processes which could be used. The BAdI on the other hand allows you to specify the exact amount of processes to be used and even allows you to change it depending on the use case.

BAdI /AEB/01_QTSK_CTRL_01

The parameter of the BAdI is a runtime context object. It offers the following methods:

  • GET_RUNTIME_CONTEXT (Provides the runtime context from which the task was created)
  • GET_USED_SERVER_GROUP_NAME (Provides the used server group)
  • GET_SERVER_GROUP_MAX_WPS_COUNT (Provides the maximum number of processes of the server group)
  • GET_MAX_WPS_TO_USE_COUNT (Provides the maximum number of processes to be used)
  • GET_INITIAL_FREE_WPS_COUNT (Provides the number of free processes at initialization)
  • SET_MAX_WPS_TO_USE_COUNT (Sets the maximum number of processes to be used)

You can set the maximum number of processes to the amount that should be used. Here is an example for the job execution of /AEB/01_FCC_RETRY_JOB.

METHOD /aeb/if_ex_01_qtsk_ctrl_01~change_spbt_runtime_parms.
  IF im_spbt_runtime_parms->get_runtime_context( ) = /aeb/cl_01_pb_spbt_contexts=>c_01_fcc_retry_job. "If the job is running
    im_spbt_runtime_parms->set_max_wps_to_use_count( 2 ). "Limit processes to 2
  ENDIF.
ENDMETHOD.

Other supported contexts can be found in the corresponding context classes:

  • /AEB/CL_01_PB_SPBT_CONTEXTS for functions available to all add-ons
  • /AEB/CL_CMP_PB_SPBT_CONTEXTS for functions of Trade Compliance Management
  • /AEB/CL_WU_PB_SPBT_CONTEXTS for functions of Origin & Preferences