SAP MDG · WORKFLOWS

How do I implement an SAP MDG dynamic agent BAdI to determine workflow approvers at runtime?

Use a dynamic agent BAdI when the MDG approval path depends on request data only known at runtime. The implementation reads the change request, derives the scenario, fills `CT_USER_AGENT_GROUP` / `CT_NON_USER_AGENT_GROUP`, and can adjust `CV_NEW_STEP` and `CV_NEW_CR_STATUS` for activation or technical routing.

Use a dynamic agent BAdI when the MDG approval path depends on request data only known at runtime. The implementation reads the change request, derives the scenario, fills `CT_USER_AGENT_GROUP` / `CT_NON_USER_AGENT_GROUP`, and can adjust `CV_NEW_STEP` and `CV_NEW_CR_STATUS` for activation or technical routing.

Dynamic agent BAdI classes in MDG are used to determine workflow approvers at runtime instead of relying only on static decision tables. The implementation reads the change request, inspects the business context, evaluates scenario-specific rules, and fills the workflow agent groups that control the next approval step. A robust pattern is to read the CR context first, resolve the scenario, collect candidate approvers, filter them against the request data, and then set the agent groups and any technical routing.

Process flow

  1. Create or identify the dynamic agent class for your MDG scenario.
  2. Implement the BAdI method used by `USMD_SSW_DYNAMIC_AGENT_SELECT`.
  3. Read the change request context and service name.
  4. Derive the scenario, such as material group, supplier company code, or request type.
  5. Select candidate approvers from your rule source or helper logic.
  6. Populate `CT_USER_AGENT_GROUP` and/or `CT_NON_USER_AGENT_GROUP`.
  7. Adjust `CV_NEW_STEP` and `CV_NEW_CR_STATUS` only if the workflow design requires a step or status change.
  8. Remove the requester from the final approver list when required by policy.','Activate the implementation and test with the correct service name and MDG model filter.

Referenced tables

ObjectPurpose
usmd_s_user_agent_groupStructure used to build user-agent group results
usmd_s_user_agentStructure used for individual user agent entries
usmd_s_non_user_agent_groupStructure used to build non-user agent group results
usmd_t_user_agent_groupTable type for returned user agent groups
usmd_t_non_user_agent_groupTable type for returned non-user agent groups
usmd_t_generic_contextGeneric context table used by many implementations
USMD120CRequest header data used in dynamic agent processing

The remaining configuration, implementation details, and testing guidance continue from this answer more…

Related questions and keywords

Alternative questions

  • How does the MDG dynamic agent BAdI route requests to the right approvers?
  • What is the implementation pattern for USMD_SSW_DYNAMIC_AGENT_SELECT?
  • How do I build CT_USER_AGENT_GROUP and CT_NON_USER_AGENT_GROUP in MDG workflow?

Possible questions

  • How do I implement an SAP MDG dynamic agent BAdI to determine workflow approvers at runtime?
  • How do I filter approvers by company code or scenario in MDG workflow?
  • How do I add a non-user agent or activation step in MDG dynamic agent logic?
  • How do I remove the requester from the final approver list in MDG?
  • Why is my MDG dynamic agent BAdI not being called?

Keywords

MDG workflow routingdynamic agent BAdIUSMD_SSW_DYNAMIC_AGENT_SELECTCT_USER_AGENT_GROUPCT_NON_USER_AGENT_GROUPCV_NEW_STEPCV_NEW_CR_STATUSUSMD_SSW_SYSTEM_METHOD_CALLERUSMD_SSW_DYNAMIC_AGENT_SELECTUSMD_SSW_SYSTEM_METHOD_CALLERUSMD_SSW_DYNAMIC_AGENT_SELECTSE19SE24USMD120Cusmd_s_user_agent_groupusmd_s_non_user_agent_groupusmd_t_generic_context