SAP MDG · UTILITIES
How do I implement MDG Change Request recall logic with workflow action validation and audit note creation in ABAP?
Use CL_USMD_WF_SERVICE to get the current recall work item, validate the CR creator with BAPI_USER_GET_DETAIL, determine the allowed recall action from USMD2301, complete the workflow step, and then write an audit note to USMD1210.
Use CL_USMD_WF_SERVICE to get the current recall work item, validate the CR creator with BAPI_USER_GET_DETAIL, determine the allowed recall action from USMD2301, complete the workflow step, and then write an audit note to USMD1210.
Use the MDG workflow service to derive the current work item for the change request, validate that the CR creator is a dialog user, pick a permitted recall action from workflow step customizing, complete the step, and finally write the recall note so the audit trail stays consistent.
Process flow
- Get the BP model instance with CL_USMD_MODEL=>GET_INSTANCE.
- Call CL_USMD_WF_SERVICE=>GET_DATA_FOR_RECALL to derive the current work item and step type.
- Read USMD120C for the CR type and creator.
- Validate the creator with BAPI_USER_GET_DETAIL and ensure a dialog user.
- Read current processors with GET_CR_WF_PROCESSORS and reject if the creator is already processing the step.
- Read allowed actions from USMD2301 for the step type.
- Pick the recall action using the documented priority order.
- Call COMPLETE_CREQUEST_WFSTEP to complete the current workflow step.
Referenced tables
| Object | Purpose |
|---|---|
USMD120C | Change request header; used to read CR type and creator. |
USMD1210 | Change request note timeline; used to write the recall note. |
USMD2301 | Workflow step action customizing; used to determine valid recall actions. |
SWW_WI2OBJ | Workflow object linkage; relevant for workflow work item resolution. |
SWWWIHEAD | Workflow work item header; relevant for workflow cleanup logic. |
ZMDG_RECALL_REAS | Custom reason-text table used by BUILD_NOTE. |
ILLUSTRATIVE ABAP SAMPLE
Source-supported ABAP pattern for MDG CR recall
This sample follows the documented recall flow for model BP and adds the audit note after successful step completion.
1METHOD recall_cr.
2 TYPES:
3 BEGIN OF ty_cr_action,
4 action_id TYPE usmd_crequest_action,
5 END OF ty_cr_action.
6
7 DATA:
8 lo_wf_service TYPE REF TO cl_usmd_wf_service,
9 lo_model TYPE REF TO if_usmd_model,
10 lt_message TYPE usmd_t_message,
11 ls_message TYPE usmd_s_message,
12 lv_wi_id TYPE sww_wiid,
13 lt_current_users TYPE usmd_t_user,
14 lv_note TYPE usmd_note,
15 ls_logondata TYPE bapilogond,
16 lt_return TYPE TABLE OF bapiret2,
17 lt_actions TYPE STANDARD TABLE OF ty_cr_action WITH KEY action_id.
18
19 lo_wf_service = cl_usmd_wf_service=>get_instance( ).
20
21 cl_usmd_model=>get_instance(
22 EXPORTING
23 i_usmd_model = 'BP'
24 IMPORTING
25 eo_instance = lo_model
26 et_message = lt_message ).
27
28 lo_wf_service->get_data_for_recall(
29 EXPORTING
30 id_crequest = iv_cr
31 IMPORTING
32 ed_step_type = DATA(lv_cr_step_type)
33 CHANGING
34 cd_wi_id = lv_wi_id ).
35
36 IF lv_wi_id IS INITIAL.
37 ls_message-msgid = 'ZMDG'.
38 ls_message-msgno = 039.
39 ls_message-msgty = 'E'.
40 APPEND ls_message TO lt_message.
41 et_message = lt_message.
42 RETURN.
43 ENDIF.
44
45 lo_wf_service->set_bor_object_key(
46 iv_bor_object_key = | BUS2250 { iv_cr WIDTH = 18 ALIGN = LEFT PAD = '0' }| ).
47
48 SELECT SINGLE usmd_creq_type, usmd_created_by
49 FROM usmd120c
50 INTO @DATA(ls_crequest)
51 WHERE usmd_crequest = @iv_cr.
52
53 IF sy-subrc <> 0.
54 ls_message-msgid = 'ZMDG'.
55 ls_message-msgno = 038.
56 ls_message-msgty = 'E'.
57 APPEND ls_message TO lt_message.
58 et_message = lt_message.
59 RETURN.
60 ENDIF.
61
62 CALL FUNCTION 'BAPI_USER_GET_DETAIL'
63 EXPORTING
64 username = ls_crequest-usmd_created_by
65 IMPORTING
66 logondata = ls_logondata
67 TABLES
68 return = lt_return.
69
70 READ TABLE lt_return WITH KEY type = 'E' TRANSPORTING NO FIELDS.
71 IF sy-subrc = 0 OR ls_logondata-ustyp <> 'A'.
72 ls_message-msgid = 'ZMDG'.
73 ls_message-msgno = 037.
74 ls_message-msgty = 'E'.
75 APPEND ls_message TO lt_message.
76 et_message = lt_message.
77 RETURN.
78 ENDIF.
79
80 lo_wf_service->get_cr_wf_processors(
81 EXPORTING
82 id_crequest = iv_cr
83 IMPORTING
84 et_uname = lt_current_users ).
85
86 READ TABLE lt_current_users WITH KEY table_line = ls_crequest-usmd_created_by TRANSPORTING NO FIELDS.
87 IF sy-subrc = 0.
88 ls_message-msgid = 'ZMDG'.
89 ls_message-msgno = 036.
90 ls_message-msgty = 'E'.
91 APPEND ls_message TO lt_message.
92 et_message = lt_message.
93 RETURN.
94 ENDIF.
95
96 SELECT usmd_cr_action
97 FROM usmd2301
98 INTO TABLE @lt_actions
99 WHERE usmd_cr_stype = @lv_cr_step_type.
100
101 IF sy-subrc <> 0.
102 ls_message-msgid = 'ZMDG'.
103 ls_message-msgno = 035.
104 ls_message-msgty = 'E'.
105 APPEND ls_message TO lt_message.
106 et_message = lt_message.
107 RETURN.
108 ENDIF.
109
110 SORT lt_actions BY action_id.
111 DATA(lv_action) = VALUE usmd_crequest_action( ).
112
113 IF ls_crequest-usmd_creq_type = 'ZSUPL6P1'.
114 READ TABLE lt_actions ASSIGNING FIELD-SYMBOL(<ls_act>) WITH KEY action_id = '06'.
115 IF sy-subrc <> 0.
116 READ TABLE lt_actions ASSIGNING <ls_act> WITH KEY action_id = '10'.
117 ENDIF.
118 ELSE.
119 READ TABLE lt_actions ASSIGNING <ls_act> WITH KEY action_id = '04'.
120 IF sy-subrc <> 0.
121 READ TABLE lt_actions ASSIGNING <ls_act> WITH KEY action_id = '06'.
122 ENDIF.
123 IF sy-subrc <> 0.
124 READ TABLE lt_actions ASSIGNING <ls_act> WITH KEY action_id = '10'.
125 ENDIF.
126 ENDIF.
127
128 IF <ls_act> IS ASSIGNED.
129 lv_action = <ls_act>-action_id.
130 ENDIF.
131
132 IF lv_action IS INITIAL.
133 ls_message-msgid = 'ZMDG'.
134 ls_message-msgno = 035.
135 ls_message-msgty = 'E'.
136 APPEND ls_message TO lt_message.
137 et_message = lt_message.
138 RETURN.
139 ENDIF.
140
141 lo_wf_service->complete_crequest_wfstep(
142 EXPORTING
143 id_crequest = iv_cr
144 id_action = lv_action
145 io_model = lo_model
146 id_wi_id = lv_wi_id
147 IMPORTING
148 et_message = lt_message ).
149
150 IF lt_message IS INITIAL.
151 ls_message-msgid = 'ZMDG'.
152 ls_message-msgno = 034.
153 ls_message-msgty = 'S'.
154 APPEND ls_message TO lt_message.
155 ENDIF.
156
157 READ TABLE lt_message WITH KEY msgty = 'S' TRANSPORTING NO FIELDS.
158 IF sy-subrc = 0.
159 build_note(
160 EXPORTING
161 iv_action = |Recall by user: { sy-uname }|
162 iv_reason_code = iv_reason_code
163 iv_additional = iv_additional
164 IMPORTING
165 ev_note = lv_note ).
166
167 add_crequest_note(
168 iv_crequest_id = iv_cr
169 iv_note = lv_note ).
170 ENDIF.
171
172 et_message = lt_message.
173ENDMETHOD.The remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- How can I recall an MDG Change Request back to the requestor?
- Which SAP MDG classes and tables are used to implement CR recall?
- How do I add a recall note to an MDG Change Request after workflow completion?
Possible questions
- How do I implement MDG Change Request recall logic with workflow action validation and audit note creation in ABAP?
- How can I recall an MDG Change Request back to the requestor?
- Which SAP MDG classes and tables are used to implement CR recall?
- How do I add a recall note to an MDG Change Request after workflow completion?
- What is the standard ABAP pattern for completing MDG workflow work items and writing CR notes?