SAP MDG · WORKFLOWS

How do I implement an MDG rule-based workflow system method caller for follow-up workflow completion, follow-up change request creation, and email notification logic in ABAP?

Implement a custom class that uses IF_USMD_SSW_SYST_METHOD_CALLER and dispatches by USMD_SERVICE_NAME: complete dependent workflow items via SAP_WAPI_* calls, derive follow-up CR data via CL_USMD_MODEL_EXT / CL_USMD_CREQUEST_API, and send notification mail with CL_BCS_MESSAGE. The source class ZCL_MDG_S_C_SYSTEM_CALL shows this exact pattern for workflow completion, follow-up CR creation, and email handling.

Implement a custom class that uses IF_USMD_SSW_SYST_METHOD_CALLER and dispatches by USMD_SERVICE_NAME: complete dependent workflow items via SAP_WAPI_* calls, derive follow-up CR data via CL_USMD_MODEL_EXT / CL_USMD_CREQUEST_API, and send notification mail with CL_BCS_MESSAGE. The source class ZCL_MDG_S_C_SYSTEM_CALL shows this exact pattern for workflow completion, follow-up CR creation, and email handling.

Use a custom class that implements IF_USMD_SSW_SYST_METHOD_CALLER and branches by USMD_SERVICE_NAME. The provided sample class ZCL_MDG_S_C_SYSTEM_CALL shows three reusable patterns: completing dependent workflow work items, creating a follow-up change request from the current CR, and sending an email notification to the CR creator. The same class also shows how to read workflow container data, change request data, and MDG model data with standard SAP APIs...

Process flow

  1. Create a final public class that implements IF_BADI_INTERFACE and IF_USMD_SSW_SYST_METHOD_CALLER.
  2. Add a CALL_SYSTEM_METHOD implementation that branches on IV_SERVICE_NAME.
  3. For workflow completion, resolve the top workflow instance with CL_USMD_WF_CREQUEST_MAPPER=>GET_TOP_WI_BY_CREQUEST_SINGLE.
  4. Read dependent work items with SAP_WAPI_GET_DEPENDENT_WIS.
  5. Complete eligible work items with SAP_WAPI_WORKITEM_COMPLETE.
  6. Read the completed work item container with SAP_WAPI_READ_CONTAINER and map ACTION_RESULT to EV_ACTION.
  7. For follow-up CR creation, create a model instance with CL_USMD_MODEL_EXT=>GET_INSTANCE and CL_USMD_MODEL=>GET_INSTANCE.
  8. Read change document header and line details with CL_USMD_MDF_CHANGE_DOCUMENT=>GET_INSTANCE, READ_DOCUMENT_HEADER, and READ_DOCUMENT_LINES if you need field-level copy logic like the sample does for delete/block scenarios; if not needed, a

Referenced tables

ObjectPurpose
USMD120CUsed in the sample to read the change request creator for email notification
SWR_WIHDRWorkflow item header table used to inspect dependent work items
SWR_CONTWorkflow container table used to read ACTION_RESULT
USMD_TS_CHANGE_DOCUMENT_VALUEHolds changed document values read from the change document API
USMD_TH_CHANGE_DOCUMENT_CHANGEHolds detailed change-document entries used for field comparisons
USMD_T_MESSAGEReturn message table for MDG system method processing
USMD_T_GENERIC_CONTEXTGeneric context table passed to system method caller services

ILLUSTRATIVE ABAP SAMPLE

Source ABAP example

Exact relevant implementation excerpt from the knowledge document.

1class ZCL_MDG_S_C_SYSTEM_CALL definition 2 public 3 final 4 create public . 5 6public section. 7 8 interfaces IF_BADI_INTERFACE . 9 interfaces IF_USMD_SSW_SYST_METHOD_CALLER . 10 11 class-methods GET_CUSTOMER_CR_DATA 12 importing 13 !IV_CR_NUMBER type USMD_CREQUEST 14 !I_READMODE type USMD_READMODE_EXT default '1' 15 exporting 16 !ET_BP_CENTRAL type ANY TABLE 17 !ET_BP_CUSGEN type ANY TABLE 18 !ET_BP_SALES type ANY TABLE 19 !ET_BP_COMPANY type ANY TABLE . 20 21 class-methods GTS_CALL 22 importing 23 !IV_CR_NUMBER type USMD_CREQUEST 24 exporting 25 !EV_ACTION type USMD_CREQUEST_ACTION 26 !ET_MESSAGE type USMD_T_MESSAGE 27 changing 28 !CT_CONTEXT_TAB type USMD_T_GENERIC_CONTEXT . 29 30 class-methods SUPPLIER_BANK_UNBLOCK 31 importing 32 !IV_CR_NUMBER type USMD_CREQUEST 33 exporting 34 !EV_ACTION type USMD_CREQUEST_ACTION 35 !ET_MESSAGE type USMD_T_MESSAGE 36 changing 37 !CT_CONTEXT_TAB type USMD_T_GENERIC_CONTEXT . 38 39 class-methods SUPPLIER_BANK_BLOCK 40 importing 41 !IV_CR_NUMBER type USMD_CREQUEST 42 exporting 43 !EV_ACTION type USMD_CREQUEST_ACTION 44 !ET_MESSAGE type USMD_T_MESSAGE 45 changing 46 !CT_CONTEXT_TAB type USMD_T_GENERIC_CONTEXT . 47protected section. 48private section. 49 50 methods FOLLOWUP_CR_SUPL_DELETE 51 importing 52 !IV_CR_NUMBER type USMD_CREQUEST 53 !IV_SERVICE_NAME type USMD_SERVICE_NAME 54 exporting 55 !ET_MESSAGE type USMD_T_MESSAGE . 56 methods GET_SUPPLIER_CR_DATA 57 importing 58 !IV_CR_NUMBER type USMD_CREQUEST 59 !I_READMODE type USMD_READMODE_EXT default '1' 60 exporting 61 !ET_BP_CENTRAL type ANY TABLE 62 !ET_BP_VENGEN type ANY TABLE 63 !ET_BP_PORG type ANY TABLE 64 !ET_BP_COMPANY type ANY TABLE . 65 methods COMPLETE_SUB_WORKFLOW 66 importing 67 !IV_CR_NUMBER type USMD_CREQUEST 68 !IV_SERVICE_NAME type USMD_SERVICE_NAME optional 69 exporting 70 !EV_ACTION type USMD_CREQUEST_ACTION . 71 methods SEND_EMAIL_NOTIFICATION 72 importing 73 !IV_CR_NUMBER type USMD_CREQUEST 74 !IV_SERVICE_NAME type USMD_SERVICE_NAME . 75 methods FOLLOWUP_CR_CUST_DELETE 76 importing 77 !IV_CR_NUMBER type USMD_CREQUEST 78 !IV_SERVICE_NAME type USMD_SERVICE_NAME 79 exporting 80 !ET_MESSAGE type USMD_T_MESSAGE . 81ENDCLASS. 82 83 84 85CLASS ZCL_MDG_S_C_SYSTEM_CALL IMPLEMENTATION. 86 87 88 method COMPLETE_SUB_WORKFLOW. 89 DATA: lt_items TYPE TABLE OF swr_wihdr, 90 lt_cont TYPE STANDARD TABLE OF swr_cont, 91 ls_cont TYPE swr_cont. 92 cl_usmd_wf_crequest_mapper=>get_top_wi_by_crequest_single( 93 EXPORTING 94 iv_crequest = iv_cr_number " Change Request 95 RECEIVING 96 rv_top_wi = DATA(lv_top_wi) " Workflow: Unique ID of Top-Level Instance (6.1/get) 97 ). 98 CALL FUNCTION 'SAP_WAPI_GET_DEPENDENT_WIS' 99 EXPORTING 100 workitem_id = lv_top_wi 101 TABLES 102 items = lt_items. 103 104 LOOP AT lt_items INTO DATA(ls_items). 105 IF ( ls_items-wi_type = 'W' AND ls_items-wi_stat = 'READY' ) OR ( ls_items-wi_type = 'F' ). 106 CALL FUNCTION 'SAP_WAPI_WORKITEM_COMPLETE' 107 EXPORTING 108 workitem_id = ls_items-wi_id. 109 110 ENDIF. 111 ENDLOOP. 112 READ TABLE lt_items INTO ls_items WITH KEY wi_type = 'W' wi_stat = 'COMPLETED'. 113 CALL FUNCTION 'SAP_WAPI_READ_CONTAINER' 114 EXPORTING 115 workitem_id = ls_items-wi_id 116 TABLES 117 simple_container = lt_cont. 118 READ TABLE lt_cont INTO ls_cont WITH KEY element = 'ACTION_RESULT'. 119 ev_action = ls_cont-value. 120 endmethod.

The remaining configuration, implementation details, and testing guidance continue from this answer more…

Related questions and keywords

Alternative questions

  • How do I implement a custom IF_USMD_SSW_SYST_METHOD_CALLER class in SAP MDG?
  • How can a system method complete dependent workflow work items from an MDG change request?
  • How do I create a follow-up change request from an existing MDG change request in ABAP?

Possible questions

  • How do I implement an MDG rule-based workflow system method caller for follow-up workflow completion, follow-up change request creation, and email notification logic in ABAP?
  • Which SAP MDG interface is used to call custom system methods in rule-based workflow?
  • How do I adapt a system method caller class for customer delete, supplier delete, or GTS scenarios?
  • How can I complete dependent workflow work items and read ACTION_RESULT from the workflow container?
  • How do I create and populate a follow-up change request from an existing change request?
  • How do I send an email notification from an MDG system method based on the change request creator?

Keywords

IF_USMD_SSW_SYST_METHOD_CALLERUSMD_CREQUESTUSMD_SERVICE_NAMEUSMD_T_MESSAGEUSMD_T_GENERIC_CONTEXTcl_usmd_wf_crequest_mapper=>get_top_wi_by_crequest_singleSAP_WAPI_GET_DEPENDENT_WISSAP_WAPI_WORKITEM_COMPLETESAP_WAPI_READ_CONTAINERACTION_RESULTcl_usmd_model_extcl_usmd_modelcl_usmd_mdf_change_documentcl_usmd_crequest_apiCREATE_FOLLOW_UP_CREQUESTREAD_TEXTBAPI_USER_GET_DETAILcl_bcs_messageUSMD120C