SAP MDG · UTILITIES

How do I implement MDG Change Request recall, cancel, workitem completion, and audit note logic in a reusable ABAP class?

Use a stateless utility class like `ZCL_MDG_CR_PROCESS_UTIL` with class methods for `RECALL_CR`, `CANCEL_CR`, `COMPLETE_WORKITEM`, `ADD_CREQUEST_NOTE`, and `BUILD_NOTE`. The pattern is: determine the workflow context, validate the CR and requestor, complete the correct workflow action, then write an audit note to `USMD1210` with `SAP_WFRT` as creator.

Use a stateless utility class like `ZCL_MDG_CR_PROCESS_UTIL` with class methods for `RECALL_CR`, `CANCEL_CR`, `COMPLETE_WORKITEM`, `ADD_CREQUEST_NOTE`, and `BUILD_NOTE`. The pattern is: determine the workflow context, validate the CR and requestor, complete the correct workflow action, then write an audit note to `USMD1210` with `SAP_WFRT` as creator.

A reusable MDG process utility class should keep workflow handling, validation, and note writing in separate static methods. For the standard pattern, `RECALL_CR` validates the current step and requestor, `CANCEL_CR` rolls back the CR and cleans up workflow items, `COMPLETE_WORKITEM` resolves READY items via workflow tables, and `ADD_CREQUEST_NOTE` persists the audit trail in `USMD1210`. `BUILD_NOTE` reads the reason text from `ZMDG_RECALL_REAS` and formats the user-facing note.

Process flow

  1. Create a final public stateless utility class `ZCL_MDG_CR_PROCESS_UTIL` with class methods only.
  2. Implement `BUILD_NOTE` to read reason text from `ZMDG_RECALL_REAS` and concatenate action, reason, and comment.
  3. Implement `ADD_CREQUEST_NOTE` to validate the CR via `CL_USMD_CREQUEST_API` and insert into `USMD1210` with `SAP_WFRT` as creator.
  4. Implement `COMPLETE_WORKITEM` using `SWW_WI2OBJ`, `SWWWIHEAD`, and `SAP_WAPI_WORKITEM_COMPLETE` to finish READY workitems.
  5. Implement `RECALL_CR` by reading workflow context, validating the requestor with `BAPI_USER_GET_DETAIL`, deriving the action from `USMD2301`, and completing the step.
  6. Implement `CANCEL_CR` by calling `CL_USMD_WF_BO_SERVICE->ROLLBACK_CREQUEST`, then cleaning up workflow items, then writing the note.
  7. Return `USMD_T_MESSAGE` to the caller for UI/service feedback.

Referenced tables

ObjectPurpose
USMD120CChange request control/header data used to identify the CR process.
USMD1210Change request note table for audit trail entries.
USMD2301Workflow step action customizing used to derive the valid recall action.
SWW_WI2OBJLinks workflow items to BOR objects for workitem resolution.
SWWWIHEADWorkflow workitem header/status table used to find READY items.
ZMDG_RECALL_REASCustom 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

  • What is the recommended ABAP utility pattern for MDG Change Request process actions?
  • How can I write recall/cancel logic for MDG CRs with workflow and notes?
  • Which APIs and tables are used to manage MDG Change Request workflow actions and notes?

Possible questions

  • How do I implement MDG Change Request recall, cancel, workitem completion, and audit note logic in a reusable ABAP class?
  • Which MDG APIs and tables are needed for CR rollback and audit notes?
  • How does a stateless utility class handle CR workflow actions in model BP?
  • How do I build a reusable ABAP helper for USMD1210 note updates and workflow completion?
  • How do I determine the recall action from USMD2301 and complete the current step?

Keywords

SAP MDGABAPChange RequestRecall CRCancel CRWorkflowUSMD1210USMD120CUSMD2301SWW_WI2OBJSWWWIHEADSAP_WAPI_WORKITEM_COMPLETECL_USMD_CREQUEST_APICL_USMD_WF_BO_SERVICECL_USMD_APP_CONTEXTZMDG_RECALL_REASmodel BP