SAP MDG · WORKFLOWS
How do I implement the MDG system method BAdI to send activation or rejection notification e-mails?
Implement `IF_USMD_SSW_SYST_METHOD_CALLER~CALL_SYSTEM_METHOD` in a class registered for BAdI `USMD_SSW_SYSTEM_METHOD_CALLER`, filter it by MDG data model in SE19, read the CR status and rejection reason from `USMD120C`, and call `ZCL_MAIL_WF=>SEND_MAIL_MDG` with notification type `S` for activation/success or `W` for rejection.
Implement `IF_USMD_SSW_SYST_METHOD_CALLER~CALL_SYSTEM_METHOD` in a class registered for BAdI `USMD_SSW_SYSTEM_METHOD_CALLER`, filter it by MDG data model in SE19, read the CR status and rejection reason from `USMD120C`, and call `ZCL_MAIL_WF=>SEND_MAIL_MDG` with notification type `S` for activation/success or `W` for rejection.
In MDG rule-based workflow, an automatic e-mail notification step is typically implemented in `IF_USMD_SSW_SYST_METHOD_CALLER~CALL_SYSTEM_METHOD`. The sample pattern reads the change request from `USMD120C`, determines whether the CR is an activation/success case or a rejection case, and delegates the actual mail sending to `ZCL_MAIL_WF=>SEND_MAIL_MDG`. The BAdI implementation is registered in `SE19` under `USMD_SSW_SYSTEM_METHOD_CALLER` and filtered by MDG data model (`0G`, `BP`, or `MM`).
Process flow
- Create or reuse a class for BAdI `
USMD_SSW_SYSTEM_METHOD_CALLER`. - Implement `IF_USMD_SSW_SYST_METHOD_CALLER~CALL_SYSTEM_METHOD`.
- Clear `ev_action` and `et_message` at the start of the method.
- Read `USMD120C` for `
USMD_REASON_REJ` and `USMD_CREQ_STATUS`. - Set notification type `S` for success/activation or `W` for rejection.
- Call `ZCL_MAIL_WF=>SEND_MAIL_MDG` with the CR number and notification type.
- Register the implementation in `SE19` and apply the MDG data model filter.
- Assign the service name in the BRF+ automatic workflow step (`DT_NON_USER_AGT_GRP_<CR>`).
Referenced tables
| Object | Purpose |
|---|---|
USMD120C | Stores the change request status and rejection reason used to decide whether the mail is an activation/success notification or a rejection notification. |
ILLUSTRATIVE ABAP SAMPLE
MDG system method e-mail notification sample
Source-supported pattern for `IF_USMD_SSW_SYST_METHOD_CALLER~CALL_SYSTEM_METHOD`; reuse the same shape and adapt the class and service name to your model and workflow step.
1CLASS zcl_badi_mm_system_method_call_sample DEFINITION
2 PUBLIC FINAL CREATE PUBLIC .
3 PUBLIC SECTION.
4 INTERFACES if_badi_interface .
5 INTERFACES if_usmd_ssw_syst_method_caller .
6ENDCLASS.
7
8
9CLASS zcl_badi_mm_system_method_call_sample IMPLEMENTATION.
10
11*======================================================================*
12* CALL_SYSTEM_METHOD - send the activation / rejection notification.
13*======================================================================*
14 METHOD if_usmd_ssw_syst_method_caller~call_system_method.
15
16* Notification types understood by the mail helper: S = success/activation, W = rejection.
17 CONSTANTS: lc_success TYPE zmdg_email_notification_type VALUE 'S',
18 lc_reject TYPE zmdg_email_notification_type VALUE 'W'.
19
20 DATA: lt_rcpt_sapid TYPE usmd_t_user_agent, " optional explicit recipients
21 lv_notif_type TYPE zmdg_email_notification_type,
22 lv_rejection TYPE usmd_reason_rej.
23
24* 1) System methods run non-interactively: always start clean.
25 CLEAR: ev_action, et_message.
26
27* 2) Read the CR's rejection reason and status from USMD120C.
28 SELECT SINGLE usmd_reason_rej FROM usmd120c
29 INTO lv_rejection WHERE usmd_crequest = iv_cr_number.
30
31 SELECT SINGLE usmd_creq_status FROM usmd120c
32 INTO @DATA(lv_creq_status) WHERE usmd_crequest = @iv_cr_number.
33
34* 3) Decide the template: rejection reason set (and not status '05') -> reject mail,
35* otherwise the success/activation mail.
36 IF lv_rejection IS NOT INITIAL AND lv_creq_status NE '05'.
37 lv_notif_type = lc_reject.
38 ELSE.
39 lv_notif_type = lc_success.
40 ENDIF.
41
42* 4) Delegate to the central MDG mail helper (resolves recipients,
43* template and body from the ZMDG_C_* mail config).
44 zcl_mail_wf=>send_mail_mdg(
45 iv_cr = iv_cr_number
46 iv_notificationtype = lv_notif_type
47 it_rcpt_sapid = lt_rcpt_sapid ).
48
49 ENDMETHOD.
50
51ENDCLASS.The remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- How can I build a system method for MDG workflow mail notifications?
- What is the ABAP pattern for
USMD_SSW_SYSTEM_METHOD_CALLERe-mail logic? - How does MDG decide between activation and rejection mail in a workflow system method?
Possible questions
- How do I implement an MDG system method BAdI for activation or rejection e-mail notification?
- How do I route a BRF+ workflow system method to a mail helper in MDG?
- Which table and BAdI are used for activation/rejection notification in MDG workflow?
- What sample ABAP code can I use for a system method e-mail notification?
- How do I filter a system method implementation by MDG data model in SE19?