SAP MDG · WORKFLOWS
How do I implement a dynamic agent BAdI in SAP MDG customer workflow routing?
Implement the dynamic-agent BAdI by reading the change request service name and status, resolving the customer scenario, filling the user or non-user agent groups, and adjusting the next workflow step/status when the request should auto-approve or go through a technical step. The supplied customer example uses `ZCL_MDG_CUST_DYN_AGNT_SELECT` with `IF_USMD_SSW_DYNAMIC_AGT_SELECT~GET_DYNAMIC_AGENTS` and routes by service name, CR creator, and GTS-allowed CR type.
Implement the dynamic-agent BAdI by reading the change request service name and status, resolving the customer scenario, filling the user or non-user agent groups, and adjusting the next workflow step/status when the request should auto-approve or go through a technical step. The supplied customer example uses `ZCL_MDG_CUST_DYN_AGNT_SELECT` with `IF_USMD_SSW_DYNAMIC_AGT_SELECT~GET_DYNAMIC_AGENTS` and routes by service name, CR creator, and GTS-allowed CR type.
Implement the MDG dynamic-agent BAdI so it routes customer requests based on runtime business data instead of static decision tables. The example class `ZCL_MDG_CUST_DYN_AGNT_SELECT` shows the standard pattern: branch on `iv_service_name`, read the request context, call a customer approver helper, optionally skip approval for follow-up requests, and insert a technical GTS step before activation when the CR type is allowed.
Process flow
- Implement `IF_USMD_SSW_DYNAMIC_AGT_SELECT~GET_DYNAMIC_AGENTS` in your custom class.
- Branch by `iv_service_name` so each workflow scenario uses the correct logic.
- Read CR context and/or `USMD120C` to determine creator, request type, and scenario.
- Call the scenario helper class to resolve approvers and populate the agent groups.
- If the request should skip approval, set the next step/status and create a technical non-user step.
- If the request needs GTS or activation handling, determine the CR type and add the technical service entry.
- Verify the service name mapping in Rule-Based Workflow customizing and retest the workflow path.
TVARVC
Maintain the allowed CR-type list used in the example for the GTS pre-activation branch under `ZMDG_GTS_ALLOWED_CR`.
Referenced tables
| Object | Purpose |
|---|---|
USMD120C | Request header data table used in the example to read the change request creator and request type. |
TVARVC | Used in the example to hold the allowed CR-type list for the GTS branch. |
ILLUSTRATIVE ABAP SAMPLE
Source ABAP example
Exact relevant implementation excerpt from the knowledge document.
1class ZCL_MDG_CUST_DYN_AGNT_SELECT 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 .
10protected section.
11private section.
12ENDCLASS.
13
14
15
16CLASS ZCL_MDG_CUST_DYN_AGNT_SELECT IMPLEMENTATION.
17
18
19 METHOD if_usmd_ssw_dynamic_agt_select~get_dynamic_agents.
20
21
22**METHOD if_usmd_ssw_dynamic_agt_select~get_dynamic_agents.
23*
24 DATA: lt_users TYPE zmdg_cust_appr_tt.
25 DATA: ls_user_agent_group TYPE usmd_s_user_agent_group,
26 ls_user_agent TYPE usmd_s_user_agent,
27 ls_non_user TYPE usmd_s_non_user_agent_group.
28* Clear exporting parameter
29 DATA: lv_act TYPE boolean VALUE abap_false.
30 DATA: lv_skip TYPE boolean VALUE abap_false.
31 DATA: lv_partner_id TYPE usmd_value.
32 CLEAR et_message.
33
34 CASE iv_service_name.
35 WHEN 'ZMDG_CUST_DYN_AGENT'. " Service for customer creation
36
37 IF cv_new_cr_status EQ '24'.
38 zcl_mdg_bp_util=>gv_first_call = abap_true.
39 zcl_mdg_bp_util=>call_gts_interface(
40 EXPORTING
41 iv_cr_number = iv_cr_number " Change Request
42 CHANGING
43 cv_partner_id = lv_partner_id
44 ).
45 ENDIF.
46* Read the approvers from TED and get The workflow steps
47 CALL METHOD zcl_mdg_cus_approvers=>get_cus_approvers
48 EXPORTING
49 iv_cr_number = iv_cr_number
50 iv_system_id = 'CUSTOMER_SET_UP'
51 IMPORTING
52 et_message = et_message
53 et_approvers = lt_users
54 CHANGING
55 cv_merge_type = cv_merge_type
56 ct_context_tab = ct_context_tab
57 cv_exp_comp_hours = cv_exp_comp_hours
58 ct_user_agent_group = ct_user_agent_group
59 ct_non_user_agent_group = ct_non_user_agent_group
60 cv_new_step = cv_new_step
61 cv_new_cr_status = cv_new_cr_status
62 cv_merge_param = cv_merge_param.
63
64 IF lt_users[] IS NOT INITIAL.
65* if cv_new_cr_status eq 25 or
66* cv_new_cr_status eq 26 or
67* cv_new_cr_status eq 27 or
68* cv_new_cr_status eq 28 or
69* cv_new_cr_status eq 29 or
70* cv_new_cr_status eq 30 or
71* cv_new_cr_status eq 32 or
72* cv_new_cr_status eq 33.
73*
74* elseif cv_new_cr_status eq 35 or cv_new_cr_status eq 37. "Added by Pawan (TE566928)
75* ls_user_agent_group-step_type = 'X'. " activate
76* endif.
77 ENDIF.
78******* end of TE476016 : end of customer creation logic call.
79* endcase.
80*
81** Clear exporting parameter
82* clear et_message.
83*
84 IF cv_new_step = '91'.
85 lv_act = abap_true.
86 ENDIF.
87* case iv_service_name.
88 WHEN 'ZMDG_CUST_DYN_AGENT_CUP2'. " Service for customer creation
89* Read the approvers from TED and get The workflow steps
90 CALL METHOD zcl_mdg_cus_approvers_cup2=>get_cus_approvers
91 EXPORTING
92 iv_cr_number = iv_cr_number
93 iv_system_id = 'CUSTOMER_SET_UP'
94 IMPORTING
95 et_approvers = lt_users
96 CHANGING
97 cv_merge_type = cv_merge_type
98 ct_context_tab = ct_context_tab
99 cv_exp_comp_hours = cv_exp_comp_hours
100 ct_user_agent_group = ct_user_agent_group
101 ct_non_user_agent_group = ct_non_user_agent_group
102 cv_new_step = cv_new_step
103 cv_new_cr_status = cv_new_cr_status
104 cv_merge_param = cv_merge_param.
105
106 IF cv_new_step = '91'.
107 lv_act = abap_true.
108 ENDIF.
109 WHEN 'ZMDG_CUST_DYN_AGENT_BLCK'.
110* CALL METHOD zcl_mdg_cus_approvers=>get_cus_blck_unblck
111* EXPORTING
112* iv_cr_number = iv_cr_number
113* iv_system_id = 'CUSTOMER_SET_UP'
114* IMPORTING
115* et_message = et_message
116* et_approvers = lt_users
117* CHANGING
118** iv_par_agt_grp_num =
119* cv_merge_type = cv_merge_type
120* ct_context_tab = ct_context_tabThe remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- How do I determine MDG workflow approvers dynamically for customer creation or block/unblock scenarios?
- Which BAdI and logic are used for customer dynamic agent selection in SAP MDG?
- How can I route SAP MDG customer requests to approvers or technical steps based on CR status and service name?
Possible questions
- How do I implement a dynamic agent BAdI in SAP MDG customer workflow routing?
- How do I determine MDG workflow approvers dynamically for customer creation or block/unblock scenarios?
- Which BAdI and logic are used for customer dynamic agent selection in SAP MDG?
- How can I route SAP MDG customer requests to approvers or technical steps based on CR status and service name?
- How do I add a GTS step before activation in a customer MDG workflow?