SAP MDG · UTILITIES
How do I implement reusable SAP MDG Change Request utility methods for cancel, recall, workitem completion, and note creation in model BP?
Use a static utility class like ZCL_MDG_CR_PROCESS_UTIL in model BP to centralize CR cancel, recall, workflow completion, and note-writing logic. The source pattern rolls back or forwards the CR, completes READY workflow items, and persists an audit note in USMD1210 with SAP_WFRT as creator.
Use a static utility class like ZCL_MDG_CR_PROCESS_UTIL in model BP to centralize CR cancel, recall, workflow completion, and note-writing logic. The source pattern rolls back or forwards the CR, completes READY workflow items, and persists an audit note in USMD1210 with SAP_WFRT as creator.
Use a reusable static utility class for MDG process actions in model BP. The documented pattern for ZCL_MDG_CR_PROCESS_UTIL centralizes cancellation, recall, workitem completion, and audit-note creation so UI handlers, exits, or service logic can call the same methods consistently. The key flow is: perform the workflow action, build a readable note from action/reason/comment text, and persist the note to USMD1210...
Process flow
- Create a final public static utility class ZCL_MDG_CR_PROCESS_UTIL.
- Implement CANCEL_CR to roll back the CR with CL_USMD_WF_BO_SERVICE->ROLLBACK_CREQUEST.
- Call COMPLETE_WORKITEM after a successful rollback to close READY workflow items.
- Build the audit note with BUILD_NOTE.
- Persist the note with ADD_CREQUEST_NOTE into USMD1210.
- Reinitialize CL_USMD_APP_CONTEXT after cancel.
- If the CR type is ZSUPBKD, call ZCL_MDG_SUPPLIER_BLK_UNBLK=>UNBLOCK_FINAL_CHECK.
- Implement RECALL_CR using CL_USMD_WF_SERVICE, CL_USMD_MODEL, BAPI_USER_GET_DETAIL, USMD2301, and COMPLETE_CREQUEST_WFSTEP.
Referenced tables
| Object | Purpose |
|---|---|
USMD120C | Change request header data, including CR type and creator. |
USMD1210 | Change request notes / audit timeline entries. |
USMD2301 | Workflow step action customizing used to derive valid recall actions. |
SWW_WI2OBJ | Workflow item to object mapping for CR-related workitems. |
SWWWIHEAD | Workflow workitem header data used to find READY items. |
ZMDG_RECALL_REAS | Custom reason text lookup for BUILD_NOTE. |
ILLUSTRATIVE ABAP SAMPLE
Source ABAP example
Exact relevant implementation excerpt from the knowledge document.
1" Reusable component export for ZCL_MDG_CR_PROCESS_UTIL
2" Exact class source export (definition + implementation)
3
4class ZCL_MDG_CR_PROCESS_UTIL definition
5 public
6 final
7 create public .
8
9public section.
10
11 class-methods CANCEL_CR
12 importing
13 !IV_CR type USMD_CREQUEST
14 !IV_REASON_CODE type USMD_NOTE optional
15 !IV_ADDITIONAL type USMD_NOTE optional
16 exporting
17 !ET_MESSAGE type USMD_T_MESSAGE .
18 class-methods COMPLETE_WORKITEM
19 importing
20 value(IV_CR) type USMD_CREQUEST optional
21 value(IV_WI) type SWW_WIID optional .
22 class-methods RECALL_CR
23 importing
24 !IV_CR type USMD_CREQUEST
25 !IV_REASON_CODE type USMD_NOTE optional
26 !IV_ADDITIONAL type USMD_NOTE optional
27 exporting
28 !ET_MESSAGE type USMD_T_MESSAGE .
29 class-methods ADD_CREQUEST_NOTE
30 importing
31 !IV_CREQUEST_ID type USMD_CREQUEST
32 !IV_NOTE type USMD_NOTE .
33 class-methods BUILD_NOTE
34 importing
35 !IV_ACTION type STRING
36 !IV_REASON_CODE type USMD_NOTE
37 !IV_ADDITIONAL type USMD_NOTE
38 exporting
39 !EV_NOTE type USMD_NOTE .
40protected section.
41private section.
42ENDCLASS.
43
44
45
46CLASS ZCL_MDG_CR_PROCESS_UTIL IMPLEMENTATION.
47
48
49METHOD add_crequest_note.
50*&H ------------------------------------------------------------------*
51*&H HEADER INFORMATION
52*&H-------------------------------------------------------------------*
53*&H Author: | TE526614
54*&H Team : | SAP MDG
55*&H Date: | 06.2026
56*$*$------------------------------------------------------------------*
57*&D Method: | ADD_CREQUEST_NOTE
58*$*$------------------------------------------------------------------*
59*&A Description:
60*&A Given a valid CR, the method will add a note the CR using the text in parameter iv_note,
61*&A the note will be created with user SAP_WFRT.
62*$*$------------------------------------------------------------------*
63
64 DATA:
65 lv_ts TYPE timestamp,
66 ls_creq_note TYPE usmd1210,
67 ls_crequest TYPE usmd_s_crequest.
68
69 TRY.
70 CALL METHOD cl_usmd_crequest_api=>get_instance
71 EXPORTING
72 iv_crequest = iv_crequest_id
73 iv_model_name = 'BP'
74 IMPORTING
75 re_inst_crequest_api = DATA(lo_crequest).
76
77 IF lo_crequest IS BOUND.
78 CALL METHOD lo_crequest->read_crequest
79 IMPORTING
80 es_crequest = ls_crequest. " Change Request
81
82 IF ls_crequest IS NOT INITIAL.
83 GET TIME STAMP FIELD lv_ts.
84
85 ls_creq_note-mandt = sy-mandt.
86 ls_creq_note-usmd_crequest = iv_crequest_id.
87 ls_creq_note-usmd_ncreated_at = lv_ts.
88 ls_creq_note-usmd_ncreated_by = 'SAP_WFRT'.
89 ls_creq_note-usmd_note = iv_note.
90
91 WAIT UP TO 1 SECONDS.
92 INSERT INTO usmd1210 VALUES ls_creq_note. "#EC CI_SUBRC
93 ENDIF.
94 ENDIF.
95 CATCH cx_usmd_gov_api INTO DATA(lx_usmd_gov_api).
96 MESSAGE lx_usmd_gov_api->get_text( ) TYPE 'E'.
97 ENDTRY.
98
99ENDMETHOD.
100
101
102 METHOD build_note.
103*&H ------------------------------------------------------------------*
104*&H HEADER INFORMATION
105*&H-------------------------------------------------------------------*
106*&H Author: | TE526614
107*&H Team : | SAP MDG
108*&H Date: | 06.2026
109*$*$------------------------------------------------------------------*
110*&D Method: | BUILD_NOTE
111*$*$------------------------------------------------------------------*
112*&A Description:
113*&A The method will build a text string to set as a note
114*&A 1. Retrive reason text from table zmdg_recall_reas
115*&A 2. Concatenate action, reason text, and additional comment in one string
116*$*$------------------------------------------------------------------*
117 CLEAR ev_note.
118
119 SELECT SINGLE reason_text
120 FROM zmdg_recall_reasThe remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- How can I cancel or recall an MDG change request with custom logic?
- How do I complete pending workflow workitems for an MDG change request?
- How do I write a note into USMD1210 for an MDG change request?
Possible questions
- How do I cancel an MDG change request and write an audit note?
- How do I recall an MDG change request back to the requester?
- How do I complete all READY workflow workitems for a CR?
- How do I add a change request note to USMD1210?
- How does BUILD_NOTE format the note text?