SAP MDG · UTILITIES
How do I implement SAP MDG change request cancel, recall, work item completion, and audit note logic in ABAP?
Use a small static utility pattern: roll back the change request with `CL_USMD_WF_BO_SERVICE`, complete pending workflow items with `SAP_WAPI_WORKITEM_COMPLETE`, build a note from action + reason text, and insert the audit note into `USMD1210` as `SAP_WFRT`.
Use a small static utility pattern: roll back the change request with `CL_USMD_WF_BO_SERVICE`, complete pending workflow items with `SAP_WAPI_WORKITEM_COMPLETE`, build a note from action + reason text, and insert the audit note into `USMD1210` as `SAP_WFRT`.
The utility pattern in `ZCL_MDG_CR_PROCESS_UTIL` is: cancel or recall the CR, complete any READY workflow items, build a human-readable note from action/reason/comment, and persist that note in `USMD1210` under `SAP_WFRT`. The same class also reinitializes the MDG app context after cancel and performs a special post-cancel check for CR type `ZSUPBKD`.
Process flow
- Implement `BUILD_NOTE` to read `REASON_TEXT` from `ZMDG_RECALL_REAS` and concatenate action, reason, and additional comment.
- Implement `ADD_CREQUEST_NOTE` using `CL_USMD_CREQUEST_API=>GET_INSTANCE` and `READ_CREQUEST` to validate the CR.
- Populate `USMD1210` with the CR number, timestamp, `SAP_WFRT`, and the built note text.
- Implement `CANCEL_CR` with `CL_USMD_WF_BO_SERVICE->ROLLBACK_CREQUEST`, then complete pending work items.
- Discard and reinitialize `CL_USMD_APP_CONTEXT` for model `BP` after cancel.
- Read the current CR type from the app context and trigger special post-cancel logic for `ZSUPBKD`.
- Implement `COMPLETE_WORKITEM` by resolving `USMD120C`, `SWW_WI2OBJ`, and `SWWWIHEAD`, then calling `SAP_WAPI_WORKITEM_COMPLETE` for READY items.
- Implement `RECALL_CR` by getting workflow data from `CL_USMD_WF_SERVICE`, validating the creator, deriving the action from `USMD2301`, and completing the workflow step.
Referenced tables
| Object | Purpose |
|---|---|
USMD1210 | Change request note timeline table used to store audit notes. |
USMD120C | Change request header table used to resolve CR data and creator information. |
USMD2301 | Change request step/action customizing used to determine allowed recall actions. |
SWW_WI2OBJ | Workflow object-to-work item mapping used to find related work items. |
SWWWIHEAD | Workflow header table used to select READY work items for completion. |
ZMDG_RECALL_REAS | Custom reason text table used by `BUILD_NOTE`. |
ILLUSTRATIVE ABAP SAMPLE
Source ABAP example
Exact relevant implementation excerpt from the knowledge document.
1" Method-wise exact code export for ZCL_MDG_CR_PROCESS_UTIL
2" Reusable copy blocks for class include usage.
3
4" ============================================================================
5" METHOD: ADD_CREQUEST_NOTE
6" ============================================================================
7METHOD add_crequest_note.
8*&H ------------------------------------------------------------------*
9*&H HEADER INFORMATION
10*&H-------------------------------------------------------------------*
11*&H Author: | TE526614
12*&H Team : | SAP MDG
13*&H Date: | 06.2026
14*$*$------------------------------------------------------------------*
15*&D Method: | ADD_CREQUEST_NOTE
16*$*$------------------------------------------------------------------*
17*&A Description:
18*&A Given a valid CR, the method will add a note the CR using the text in parameter iv_note,
19*&A the note will be created with user SAP_WFRT.
20*$*$------------------------------------------------------------------*
21
22 DATA:
23 lv_ts TYPE timestamp,
24 ls_creq_note TYPE usmd1210,
25 ls_crequest TYPE usmd_s_crequest.
26
27 TRY.
28 CALL METHOD cl_usmd_crequest_api=>get_instance
29 EXPORTING
30 iv_crequest = iv_crequest_id
31 iv_model_name = 'BP'
32 IMPORTING
33 re_inst_crequest_api = DATA(lo_crequest).
34
35 IF lo_crequest IS BOUND.
36 CALL METHOD lo_crequest->read_crequest
37 IMPORTING
38 es_crequest = ls_crequest. " Change Request
39
40 IF ls_crequest IS NOT INITIAL.
41 GET TIME STAMP FIELD lv_ts.
42
43 ls_creq_note-mandt = sy-mandt.
44 ls_creq_note-usmd_crequest = iv_crequest_id.
45 ls_creq_note-usmd_ncreated_at = lv_ts.
46 ls_creq_note-usmd_ncreated_by = 'SAP_WFRT'.
47 ls_creq_note-usmd_note = iv_note.
48
49 WAIT UP TO 1 SECONDS.
50 INSERT INTO usmd1210 VALUES ls_creq_note. "#EC CI_SUBRC
51 ENDIF.
52 ENDIF.
53 CATCH cx_usmd_gov_api INTO DATA(lx_usmd_gov_api).
54 MESSAGE lx_usmd_gov_api->get_text( ) TYPE 'E'.
55 ENDTRY.
56
57ENDMETHOD.
58
59" ============================================================================
60" METHOD: BUILD_NOTE
61" ============================================================================
62METHOD build_note.
63*&H ------------------------------------------------------------------*
64*&H HEADER INFORMATION
65*&H-------------------------------------------------------------------*
66*&H Author: | TE526614
67*&H Team : | SAP MDG
68*&H Date: | 06.2026
69*$*$------------------------------------------------------------------*
70*&D Method: | BUILD_NOTE
71*$*$------------------------------------------------------------------*
72*&A Description:
73*&A The method will build a text string to set as a note
74*&A 1. Retrive reason text from table zmdg_recall_reas
75*&A 2. Concatenate action, reason text, and additional comment in one string
76*$*$------------------------------------------------------------------*
77 CLEAR ev_note.
78
79 SELECT SINGLE reason_text
80 FROM zmdg_recall_reas
81 INTO @DATA(lv_reason)
82 WHERE reason_id = @iv_reason_code.
83
84 IF sy-subrc = 0.
85 ev_note = |{ iv_action } { ' , ' } { lv_reason } { ' Additional Comment: '(003) }{ iv_additional }|.
86 ENDIF.
87
88ENDMETHOD.
89
90" ============================================================================
91" METHOD: CANCEL_CR
92" ============================================================================
93METHOD cancel_cr.
94*&H ------------------------------------------------------------------*
95*&H HEADER INFORMATION
96*&H-------------------------------------------------------------------*
97*&H Author: | TE526614
98*&H Team : | SAP MDG
99*&H Date: | 06.2026
100*$*$------------------------------------------------------------------*
101*&D Method: | CANCEL_CR
102*$*$------------------------------------------------------------------*
103*&A Description:
104*&A Given a valid CR, the method will cancel the CR,
105*&A then adding a note to CR to explain the reason of cancelation
106*$*$------------------------------------------------------------------*
107
108 DATA:
109 ls_message TYPE usmd_s_message,
110 lt_message TYPE usmd_t_message,
111 lv_note TYPE usmd_note,
112 lv_action TYPE usmd_crequest_action,
113 lo_cr TYPE REF TO cl_usmd_wf_bo_service,
114 lo_context TYPE REF TO if_usmd_app_context,
115 lt_context_tab TYPE usmd_t_generic_context.
116
117 CREATE OBJECT lo_cr.
118
119 CALL METHOD lo_cr->rollback_crequest
120 EXPORTINGThe remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- How can I cancel an SAP MDG change request and write a note?
- How do I recall an SAP MDG change request to the requester?
- How do I complete pending workflow work items for an MDG change request?
Possible questions
- Which MDG class writes a note into USMD1210?
- How is a change request cancellation handled in ZCL_MDG_CR_PROCESS_UTIL?
- How do I build a standardized MDG note from action, reason, and comment?
- Which tables and APIs are used for MDG cancel/recall processing?
- How does the utility determine the workflow action for recall?