SAP MDG · UTILITIES
How do I implement SAP MDG change request recall, cancel, workflow completion, and note logging for model BP?
Use a static utility class like `ZCL_MDG_CR_PROCESS_UTIL` for BP-model MDG change request handling: rollback or recall the CR, complete pending workflow items, and write an audit note to `USMD1210`. The documented pattern uses `CL_USMD_WF_BO_SERVICE`, `SAP_WAPI_WORKITEM_COMPLETE`, `CL_USMD_CREQUEST_API`, `CL_USMD_APP_CONTEXT`, and workflow customizing in `USMD2301`.
Use a static utility class like `ZCL_MDG_CR_PROCESS_UTIL` for BP-model MDG change request handling: rollback or recall the CR, complete pending workflow items, and write an audit note to `USMD1210`. The documented pattern uses `CL_USMD_WF_BO_SERVICE`, `SAP_WAPI_WORKITEM_COMPLETE`, `CL_USMD_CREQUEST_API`, `CL_USMD_APP_CONTEXT`, and workflow customizing in `USMD2301`.
Use a reusable static utility class for BP-model MDG change request processing. The documented pattern combines CR rollback or recall, workflow item completion, and note logging so the UI or process exit can call one method and receive `USMD_T_MESSAGE` back.
Process flow
- Create a static utility class `ZCL_MDG_CR_PROCESS_UTIL` with class methods only.
- Implement `CANCEL_CR` to call `CL_USMD_WF_BO_SERVICE->ROLLBACK_CREQUEST` and collect `
USMD_T_MESSAGE`. - If cancel rollback has no error, call `COMPLETE_WORKITEM` to finish READY workflow items.
- Reinitialize the MDG application context with `CL_USMD_APP_CONTEXT` and check the CR type.
- If the CR type is `ZSUPBKD`, run the additional unblock check shown in the source pattern.
- Implement `RECALL_CR` by validating the creator user with `BAPI_USER_GET_DETAIL`, reading the valid action from `USMD2301`, and completing the current step.
- Implement `ADD_CREQUEST_NOTE` to validate the CR via `CL_USMD_CREQUEST_API`, fill `USMD1210`, and insert the note.
- Implement `BUILD_NOTE` to combine action, reason text from `ZMDG_RECALL_REAS`, and additional comments into one `
USMD_NOTE`.`,`Return `USMD_T_MESSAGE` to the caller in all workflow methods.
Referenced tables
| Object | Purpose |
|---|---|
USMD120C | Change request type and process-related metadata referenced during CR processing. |
USMD1210 | Change request note timeline table where audit comments are inserted. |
USMD2301 | Workflow step action customizing used to determine valid recall action. |
SWW_WI2OBJ | Workflow link table used to resolve workflow items bound to the CR BOR instance. |
SWWWIHEAD | Workflow header table used to find top and child READY work items. |
ZMDG_RECALL_REAS | Custom reason-code text table used by `BUILD_NOTE`. |
ILLUSTRATIVE ABAP SAMPLE
Source ABAP example: Change Request Report.abap
Exact relevant implementation excerpt from the knowledge document set.
1*&---------------------------------------------------------------------*
2*& Report CHANGE_REQUEST_REPORT
3*&---------------------------------------------------------------------*
4*& Purpose:
5*& This report creates a flattened, non-modular view of the change
6*& request extraction logic from ZMDG_CHANGE_REQUEST_REPORT.
7*&
8*& What it does:
9*& - Reads change requests of type ZSUP* created in a time window
10*& - Resolves the BP technical key from USMD1213
11*& - Finds the dynamic generated staging table for BP data
12*& - Reads organizational and vendor-specific data dynamically
13*& - Combines header data and staging data into ZMDG_CHGREQ
14*& - Updates the target table with the generated results
15*&
16*& This file is intentionally flattened so the full flow can be studied
17*& without navigating includes or FORM modularization.
18*&---------------------------------------------------------------------*
19
20REPORT zmdg_change_request_report.
21
22"---------------------------------------------------------------------
23" Global data declarations from the TOP include
24" These variables hold the selection window, technical keys, dynamic
25" table references, and the final output rows.
26"---------------------------------------------------------------------
27DATA: gv_low TYPE timestamp,
28 gv_high TYPE timestamp,
29 gv_sid TYPE usmd_flg,
30 gt_techkey TYPE TABLE OF usmd_tech_key,
31 gs_techkey TYPE usmd_tech_key,
32 gt_techkey1 TYPE TABLE OF usmd_tech_key,
33 gt_usmd1210 TYPE STANDARD TABLE OF usmd1210,
34 gs_final TYPE zmdg_chgreq.
35
36" Range table for filtering change request types.
37DATA: gr_type TYPE RANGE OF usmd_crequest_type.
38
39" Helper structures for dynamic field handling.
40DATA: lt_key_fields_range TYPE RANGE OF name_komp,
41 lt_key_fields TYPE TABLE OF name_komp,
42 ls_key_data TYPE REF TO data,
43 go_data TYPE REF TO data.
44
45FIELD-SYMBOLS: <lfs_t_org_data> TYPE ANY TABLE,
46 <lfs_t_vengen> TYPE ANY TABLE.
47
48DATA: gr_data TYPE REF TO data.
49
50" Change request header data and intermediate technical-key mapping data.
51DATA: lt_usmd1213 TYPE TABLE OF usmd1213,
52 ls_usmd1213 TYPE usmd1213,
53 lt_usmd120c TYPE TABLE OF usmd120c,
54 ls_usmd120c TYPE usmd120c.
55
56" Final output buffer to be written to ZMDG_CHGREQ.
57DATA: gt_data TYPE TABLE OF zmdg_chgreq,
58 gs_data TYPE zmdg_chgreq.
59
60" Empty selection-screen include from the original program.
61" The original include exists only as a placeholder, so the flat version
62" keeps the same structure but does not add custom selection fields.
63
64"---------------------------------------------------------------------
65" Main execution flow
66"---------------------------------------------------------------------
67START-OF-SELECTION.
68 " Read and prepare the source data first.
69 PERFORM get_data.
70
71END-OF-SELECTION.
72 " After data extraction, build the final output rows and persist them.
73 PERFORM process_data.
74
75"---------------------------------------------------------------------
76" FORM get_data
77" Purpose:
78" Collect all change requests and staging-table data needed to build
79" the flattened change request report.
80"---------------------------------------------------------------------
81FORM get_data.
82
83 " Reset key runtime variables before the extraction starts.
84 CLEAR: gv_low, gv_high, gv_sid, gt_techkey.
85
86 " Only change request types that start with ZSUP are relevant.
87 gr_type = VALUE #( ( sign = 'I' option = 'CP' low = 'ZSUP*' ) ).
88
89 "---------------------------------------------------------------
90 " Determine the extraction time window.
91 " If TVARVC contains a saved low timestamp, use it; otherwise use
92 " the current timestamp and subtract one month.
93 "---------------------------------------------------------------
94 SELECT SINGLE * FROM tvarvc
95 INTO @DATA(ls_tvarvc)
96 WHERE name = 'ZMDG_REPORT2ONEDATA'.
97 IF sy-subrc = 0 AND ls_tvarvc-low IS NOT INITIAL.
98 gv_low = ls_tvarvc-low.
99 ELSE.
100 GET TIME STAMP FIELD DATA(lv_current_timestamp).
101 CONVERT TIME STAMP lv_current_timestamp TIME ZONE 'UTC'
102 INTO DATE DATA(lv_date)
103 TIME DATA(lv_time).
104 TRY.
105 cl_hrpad_date_computations=>add_months_to_date(
106 EXPORTING
107 start_date = lv_date
108 months = -1
109 RECEIVING
110 date = DATA(lv_past_date)
111 ).
112 CATCH cx_hrpa_violated_postcondition.
113 " Fallback if month subtraction hits a date postcondition.
114 lv_past_date = lv_date - 30.
115 ENDTRY.
116 CONVERT DATE lv_past_date TIME lv_time
117 INTO TIME STAMP DATA(lv_target_timestamp) TIME ZONE 'UTC'.
118 gv_low = lv_target_timestamp.
119 gv_high = lv_current_timestamp.
120 ENDIF.The remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- How can I programmatically recall or cancel an MDG change request in BP?
- Which classes and tables are used to complete MDG workflow work items and write CR notes?
- How do I build a reusable MDG CR process utility in ABAP?
Possible questions
- How do I implement SAP MDG change request recall, cancel, workflow completion, and note logging for model BP?
- Which classes and tables are used to complete MDG workflow work items and write CR notes?
- How do I build a reusable MDG CR process utility in ABAP?
- How can I programmatically recall or cancel an MDG change request in BP?
- How does a static MDG utility class handle CR workflow actions and notes?