SAP MDG · UTILITIES
How do I set up MDG e-mail notifications after approval or activation?
Use the MDG workflow email framework to trigger a mail after approval or activation, resolve recipients dynamically, and build the body from change-request data, change history, or workflow context. The documented pattern uses a copied workflow, a workflow exit class, a Send Mail step, and the standard outbound mail API.
Use the MDG workflow email framework to trigger a mail after approval or activation, resolve recipients dynamically, and build the body from change-request data, change history, or workflow context. The documented pattern uses a copied workflow, a workflow exit class, a Send Mail step, and the standard outbound mail API.
Use the MDG workflow email pattern to send notifications after approval or activation. The framework identifies the trigger event, resolves recipients from configuration or master data, fills template placeholders from change-request data, and sends the mail through the standard outbound API. In the documented process, a copied workflow adds a Send Mail step after activation, uses `EMAILRECEIVER` as the recipient expression, and can include a dynamic CR subject plus the CR object list in the body.
Process flow
- Create workflow container `EMAILRECEIVER` with type `SWHACTOR` and Import + Export + Multiline.
- Create workflow container `CREQUEST_OBJLIST` with type `ZUSMD_T_ENTITY` and Import + Export.
- Copy task `000298 Activate Changes` to `ZCREQ_ACTIVE`.
- Add the same two task-container elements and create two-way bindings.
- Create class `ZCL_EMAIL_NOTIFICATION_WF_EXIT` and implement `IF_SWF_IFS_WORKITEM_EXIT` and `EVENT_RAISED`.
- Assign the class as the program exit.
- Add a Send Mail step after Activate Changes.
- Use `EMAILRECEIVER` as the recipient expression and add a dynamic CR subject plus `CREQUEST_OBJLIST` to the body. Create task `ZSEND_MAIL` and verify binding. Create and activate the runtime version, define workflow step numbers, and assign
Referenced tables
| Object | Purpose |
|---|---|
USMD1210 | Change request notes persistence used in related MDG helper logic. |
mdg_user_proxy_setting | Proxy persistence and change-request routing setting used in related MDG service patterns. |
ILLUSTRATIVE ABAP SAMPLE
Source ABAP example: fetch_slg1_logs.abap
Exact relevant implementation excerpt from the knowledge document set.
1METHOD fetch_slg1_logs.
2
3**Data Declarations
4 DATA:ld_extnum TYPE balnrext,
5 ld_pattern TYPE string,
6 ld_cr_activation_pattern TYPE string,
7 lt_messages TYPE STANDARD TABLE OF balm,
8 ls_msg_output TYPE bapiret2,
9 ld_recent_date TYPE cva_date,
10 ld_date TYPE cva_date,
11 ld_recent_time TYPE cva_time,
12 ld_time TYPE cva_time,
13 ld_date_diff TYPE i,
14 ld_time_diff TYPE cva_time,
15 ld_sec TYPE i.
16
17**Fetch Pattern
18 CONCATENATE 'CRequest Activation-' iv_crequest_id INTO ld_cr_activation_pattern.
19
20**Fetch External Number
21 ld_extnum = ld_cr_activation_pattern.
22
23**Fetch SLG1 Logs
24 CALL FUNCTION 'APPL_LOG_READ_DB'
25 EXPORTING
26 external_number = ld_extnum
27 TABLES
28 messages = lt_messages.
29
30**Sort messages based on Time Stamp Descending
31 SORT lt_messages BY time_stmp DESCENDING.
32
33**Delete messages that do not belong to the input message type
34 DELETE lt_messages WHERE msgty NE iv_message_type.
35
36**Fetch Latest Message Entry, Date and Time
37 READ TABLE lt_messages ASSIGNING FIELD-SYMBOL(<ls_latest_record>) INDEX 1.
38 IF <ls_latest_record> IS ASSIGNED.
39 CONVERT TIME STAMP <ls_latest_record>-time_stmp TIME ZONE sy-zonlo
40 INTO DATE ld_recent_date TIME ld_recent_time.
41 ENDIF.
42
43**Latest messages are being formatted
44 LOOP AT lt_messages ASSIGNING FIELD-SYMBOL(<ls_messages>).
45
46**Fetch Date and Time of the Message Entry
47 CONVERT TIME STAMP <ls_messages>-time_stmp TIME ZONE sy-zonlo
48 INTO DATE ld_date TIME ld_time.
49
50**Fetch Date and Time difference
51 CALL FUNCTION 'SCOV_TIME_DIFF'
52 EXPORTING
53 im_date1 = ld_date
54 im_date2 = ld_recent_date
55 im_time1 = ld_time
56 im_time2 = ld_recent_time
57 IMPORTING
58 ex_days = ld_date_diff
59 ex_time = ld_time_diff
60 EXCEPTIONS
61 start_larger_than_end = 1
62 OTHERS = 2.
63 IF sy-subrc <> 0.
64* Implement suitable error handling here
65 ENDIF.
66
67**Fetch Time Difference in seconds
68 ld_sec = ( ( ld_time_diff+0(2) * 3600 ) + ( ld_time_diff+2(2) * 60 ) + ld_time_diff+4(2) ).
69
70**When Time Difference is less than or equal to 2 minutes
71 IF ld_date_diff LE 0 AND ld_sec LE 120.
72
73 CALL FUNCTION 'MESSAGE_TEXT_BUILD'
74 EXPORTING
75 msgid = <ls_messages>-msgid
76 msgnr = <ls_messages>-msgno
77 msgv1 = <ls_messages>-msgv1
78 msgv2 = <ls_messages>-msgv2
79 msgv3 = <ls_messages>-msgv3
80 msgv4 = <ls_messages>-msgv4
81 IMPORTING
82 message_text_output = ls_msg_output-message.
83
84**Push messages to output messages structure
85 APPEND ls_msg_output TO et_messages.
86 CLEAR ls_msg_output.
87
88 ENDIF.
89
90 ENDLOOP.
91
92 ENDMETHOD.The remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- How can I send an MDG mail after approval?
- How can I send an MDG mail after activation?
- How do I configure a non-work-item MDG e-mail notification?
Possible questions
- How do I set up MDG e-mail notifications after approval or activation?
- How can I send an MDG mail after approval?
- How can I send an MDG mail after activation?
- How do I configure a non-work-item MDG e-mail notification?
- How do I add a change request link and object list to an MDG e-mail?
- How do I monitor MDG e-mails in SOST?