SAP MDG · WORKFLOWS
How do I implement dynamic workflow agent selection in SAP MDG for supplier and customer change requests?
Use `IF_USMD_SSW_DYNAMIC_AGT_SELECT` to build runtime approver routing, fill `CT_USER_AGENT_GROUP` or `CT_NON_USER_AGENT_GROUP`, and adjust `CV_NEW_STEP` / `CV_NEW_CR_STATUS` based on the change request scenario. The sample class `ZCL_MDG_S_C_SELECT_DYN_AGENT` shows supplier and customer branching, requester exclusion, and optional activation handling.
Use `IF_USMD_SSW_DYNAMIC_AGT_SELECT` to build runtime approver routing, fill `CT_USER_AGENT_GROUP` or `CT_NON_USER_AGENT_GROUP`, and adjust `CV_NEW_STEP` / `CV_NEW_CR_STATUS` based on the change request scenario. The sample class `ZCL_MDG_S_C_SELECT_DYN_AGENT` shows supplier and customer branching, requester exclusion, and optional activation handling.
Use `IF_USMD_SSW_DYNAMIC_AGT_SELECT` to determine approvers at runtime in SAP MDG. The sample class `ZCL_MDG_S_C_SELECT_DYN_AGENT` shows the pattern: read the change request, identify the service name, derive the next approver role, fetch the relevant approver list, remove the requester from the result, and either route to `CT_USER_AGENT_GROUP` or switch to a technical activation path via `CT_NON_USER_AGENT_GROUP`.
Process flow
- Implement `IF_USMD_SSW_DYNAMIC_AGT_SELECT` in the dynamic agent class.
- Check `IV_SERVICE_NAME` and branch by supplier/customer scenario.
- Read CR context and request metadata.
- Determine the next approver role or activation flag.
- Fetch approvers for the selected role.
- Remove the CR creator from the approver list.
- Populate `CT_USER_AGENT_GROUP` or `CT_NON_USER_AGENT_GROUP`.
- Set `CV_NEW_STEP` and `CV_NEW_CR_STATUS`.
Referenced tables
| Object | Purpose |
|---|---|
USMD120C | Change request header data, including `USMD_CREATED_BY` and CR type information. |
ZMDG_STATUS_TED | Maps role name to the new change-request status used by the dynamic agent logic. |
ILLUSTRATIVE ABAP SAMPLE
Source ABAP example
Exact relevant implementation excerpt from the knowledge document.
1class ZCL_MDG_S_C_SELECT_DYN_AGENT definition
2 public
3 final
4 create public .
5
6public section.
7
8 interfaces IF_BADI_INTERFACE .
9 interfaces IF_USMD_SSW_DYNAMIC_AGT_SELECT .
10
11 types:
12 BEGIN OF ty_cr_data_customer,
13 acc_group TYPE ktokd,
14 sales_office TYPE vkbur,
15 company TYPE bukrs,
16 bu_code TYPE katr6,
17 industry_code TYPE brsch,
18 country TYPE land1,
19 region TYPE char4,
20 lang TYPE sprast,
21 credit_rep_group TYPE char20,
22 payment_term TYPE char20,
23 block_code TYPE aufsd,
24 exclusion_bu_appr TYPE zmdg_de_exclgrp,
25 END OF ty_cr_data_customer .
26 types:
27 BEGIN OF ty_cr_data_supplier,
28 acc_grp TYPE ktokk,
29 commodity TYPE matkl,
30 major_commodity TYPE char2,
31 region_id TYPE char4,
32 country TYPE land1,
33 pu_dept TYPE zmdg_de_pu_dept,
34 zppaind TYPE zz_ppa_ind,
35 END OF ty_cr_data_supplier .
36
37 data:
38 gt_cr_data_supplier TYPE STANDARD TABLE OF ty_cr_data_supplier .
39 data:
40 GT_CR_DATA_CUSTOMER TYPE STANDARD TABLE OF TY_CR_DATA_CUSTOMER .
41
42 methods GET_CR_DATA
43 importing
44 !IV_CR_NUMBER type USMD_CREQUEST
45 exporting
46 !EV_KTOKD type KTOKD
47 !EV_KTOKK type KTOKK .
48protected section.
49private section.
50
51 methods GET_STEP_NUMBER
52 importing
53 !IV_CR_NUMBER type USMD_CREQUEST
54 exporting
55 !EV_STEP_NUMBER type USMD_CREQUEST_APPSTEP .
56 methods GET_NEXT_APPROVER_ROLE
57 importing
58 !IV_CR_NUMBER type USMD_CREQUEST
59 !IV_SERVICE_NAME type USMD_SERVICE_NAME optional
60 exporting
61 !EV_ROLE type AGR_NAME
62 !EV_ACTIVATE type BOOLEAN
63 changing
64 !CT_CONTEXT_TAB type USMD_T_GENERIC_CONTEXT optional .
65 methods GET_APPROVER_LIST
66 importing
67 !IV_ROLE type AGR_NAME optional
68 !IV_SERVICE_NAME type USMD_SERVICE_NAME
69 !IV_CR_NUMBER type USMD_CREQUEST
70 changing
71 !CT_USER_AGENT_GROUP type USMD_T_USER_AGENT_GROUP
72 !CT_CONTEXT_TAB type USMD_T_GENERIC_CONTEXT
73 !CT_NON_USER_AGENT_GROUP type USMD_T_NON_USER_AGENT_GROUP
74 !CV_NEW_STEP type USMD_CREQUEST_APPSTEP
75 !CV_NEW_CR_STATUS type USMD_CREQUEST_STATUS .
76 methods SET_ACTIVATE_CR
77 importing
78 !IV_CR_ID type USMD_CREQUEST
79 changing
80 !CV_NEW_STEP type USMD_CREQUEST_APPSTEP
81 !CV_NEW_CR_STATUS type USMD_CREQUEST_STATUS
82 !CT_NON_USER_AGENT_GROUP type USMD_T_NON_USER_AGENT_GROUP .
83ENDCLASS.
84
85
86
87CLASS ZCL_MDG_S_C_SELECT_DYN_AGENT IMPLEMENTATION.
88
89
90 METHOD get_approver_list.
91 DATA: ls_cr_data_supplier TYPE ty_cr_data_supplier,
92 ls_cr_data_customer TYPE ty_cr_data_customer,
93 lv_agent_grp TYPE numc3 VALUE '000',
94 lt_sel TYPE usmd_ts_sel,
95 ls_sel TYPE usmd_s_sel,
96 lt_user_id TYPE usmd_t_user_agent,
97 lt_cus_appr TYPE zmdg_t_ted_cus_appr,
98 lt_sup_appr TYPE zmdg_t_ted_sup_appr,
99* lt_approver TYPE zmdg_t_ted_appr,
100 ls_sup_approver LIKE LINE OF lt_sup_appr,
101 lt_sup_appr_copy1 TYPE zmdg_t_ted_sup_appr,
102 ls_cus_approver LIKE LINE OF lt_cus_appr,
103 ls_cus_appr LIKE LINE OF lt_cus_appr,
104 lt_cus_appr_copy1 TYPE zmdg_t_ted_cus_appr,
105 lt_approver_copy2 TYPE zmdg_t_ted_sup_appr,
106 lv_status TYPE usmd_crequest_status,
107 lv_role TYPE agr_name,
108 lv_activate TYPE boolean.
109 DATA: lt_user TYPE usmd_t_user_agent.
110
111 DATA: lv_is_comm_app_reqd TYPE boolean, " Flag is commodity Approer Reqd
112 lv_is_smev_app_reqd TYPE boolean, " Flag is SME Approver Reqd
113 lv_is_purch_app_reqd TYPE boolean, " Flag is Purchasing Approver Reqd
114 lv_is_payterm_app_reqd TYPE boolean, " Flag is Payterm Approver Reqd
115 lv_is_clasif_app_reqd TYPE boolean, " Flag is Classif Approver Reqd
116 lv_is_legal_app_reqd TYPE boolean, " Flag is Legal Approver Reqd
117 lv_is_diver_app_reqd TYPE boolean, " Flag is Diversity Approver Reqd
118 lv_is_buyer_app_reqd TYPE boolean, " Flag is Buyer Approver Reqd
119 lv_is_qual_app_reqd TYPE boolean. " Flag is Qual Approver Reqd
120 DATA: lt_approver_sup TYPE txlft_string.The remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- How can I route SAP MDG supplier and customer change requests to different approvers at runtime?
- How do I build a dynamic agent BAdI for MDG workflow approval?
- How do I set up runtime approver determination for supplier and customer MDG requests?
Possible questions
- Which BAdI is used for dynamic agent determination in SAP MDG?
- How does the MDG dynamic agent class decide the next approver role?
- How do I remove the request creator from the approver list in MDG?
- How do I trigger automatic activation or a technical step from MDG workflow?
- What workflow structures are typically filled by the dynamic agent implementation?