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
- Create or identify the dynamic agent class for your MDG scenario.
- Implement the BAdI method used by `
USMD_SSW_DYNAMIC_AGENT_SELECT`. - Read the change request context and service name.
- Derive the scenario, such as material group, supplier company code, or request type.
- Select candidate approvers from your rule source or helper logic.
- Populate `CT_USER_AGENT_GROUP` and/or `CT_NON_USER_AGENT_GROUP`.
- Adjust `CV_NEW_STEP` and `CV_NEW_CR_STATUS` only if the workflow design requires a step or status change.
- 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
| Object | Purpose |
|---|---|
usmd_s_user_agent_group | Structure used to build user-agent group results |
usmd_s_user_agent | Structure used for individual user agent entries |
usmd_s_non_user_agent_group | Structure used to build non-user agent group results |
usmd_t_user_agent_group | Table type for returned user agent groups |
usmd_t_non_user_agent_group | Table type for returned non-user agent groups |
usmd_t_generic_context | Generic context table used by many implementations |
USMD120C | Request 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?