SAP MDG · UTILITIES

How do I refresh an SAP MDG Business Partner change request snapshot in ABAP when I already know the BP number?

Use CL_USMD_CREQUEST_API to retrieve the active Business Partner change request for BP_HEADER, initialize the MDG app context with CL_USMD_APP_CONTEXT, then call CL_USMD_SNAPSHOT_TOOLS=>refresh_snapshot_for_cr to refresh the snapshot and return messages / failure flag.

Use CL_USMD_CREQUEST_API to retrieve the active Business Partner change request for BP_HEADER, initialize the MDG app context with CL_USMD_APP_CONTEXT, then call CL_USMD_SNAPSHOT_TOOLS=>refresh_snapshot_for_cr to refresh the snapshot and return messages / failure flag.

In SAP MDG Business Partner processing, the standard refresh pattern is: normalize the BP number, retrieve the active change request for BP_HEADER, initialize the MDG application context for that change request, and then refresh the snapshot. The method pattern below shows the exact API sequence used in the source example.

Process flow

  1. Convert the incoming BP number with CONVERSION_EXIT_ALPHA_INPUT.
  2. Populate a USMD_S_VALUE row for entity BP_HEADER.
  3. Call CL_USMD_CREQUEST_API=>if_usmd_crequest_api~retrieve_crequest with iv_entity = 'BP_HEADER' and iv_model = 'BP'.
  4. Check whether a running change request was returned in USMD_TS_CREQUEST.
  5. If found, call CL_USMD_APP_CONTEXT=>init_context with the change request ID.
  6. Call CL_USMD_SNAPSHOT_TOOLS=>refresh_snapshot_for_cr to refresh the snapshot.
  7. Handle ET_MESSAGE and EV_FAILED from the refresh call.

Referenced tables

ObjectPurpose
USMD1210Used by related change-request note logic in the same utility package.
USMD120CUsed in related change-request and process-determination logic in the same utility package.
BUT000Business Partner master data source for the BP number used in the refresh pattern.
BUT100Business Partner role source referenced in the same utility package.

ILLUSTRATIVE ABAP SAMPLE

Source ABAP example

Exact relevant implementation excerpt from the knowledge document.

1METHOD mdg_refresh_change_request. 2 TYPES: BEGIN OF ty_but000, 3 partner TYPE but000-partner, 4 bu_group TYPE but000-bu_group, 5 type TYPE but000-type, 6 partner_guid TYPE but000-partner_guid, 7 END OF ty_but000, 8 9 BEGIN OF ty_but100, 10 partner TYPE but100-partner, 11 rltyp TYPE bu_partnerrole, 12 END OF ty_but100. 13 14 15 DATA: 16 ls_crequest TYPE usmd_s_crequest, 17 ls_usmd_value TYPE usmd_s_value, 18 lt_usmd_value TYPE usmd_ts_value, 19 lt_mdg_message TYPE usmd_t_message, 20 lt_crequest TYPE usmd_ts_crequest, 21 lv_partner TYPE bu_partner. 22 23 CLEAR: lt_usmd_value, lt_crequest, ls_crequest. 24 25 lv_partner = iv_partner. 26 27 CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' 28 EXPORTING 29 input = lv_partner 30 IMPORTING 31 output = lv_partner. 32 33 ls_usmd_value-fieldname = 'BP_HEADER'. 34 ls_usmd_value-value = lv_partner. 35 INSERT ls_usmd_value INTO TABLE lt_usmd_value. 36 37 38 CALL METHOD cl_usmd_crequest_api=>if_usmd_crequest_api~retrieve_crequest 39 EXPORTING 40 iv_entity = 'BP_HEADER' 41 it_entity_key = lt_usmd_value 42 iv_model = 'BP' 43 if_activeonly = abap_true 44 IMPORTING 45 et_crequest = lt_crequest 46 et_message = lt_mdg_message. 47 48 LOOP AT lt_crequest INTO ls_crequest. 49 ENDLOOP. 50 "& CHECK IF BP HAVE A RUNNING CR 51 IF ls_crequest-usmd_crequest IS NOT INITIAL. 52 ev_crequest = ls_crequest-usmd_crequest. 53 TRY. 54 cl_usmd_app_context=>init_context( iv_crequest_id = ls_crequest-usmd_crequest ). 55 CATCH cx_usmd_app_context_cons_error ##NO_HANDLER. 56 ENDTRY. 57 58 cl_usmd_snapshot_tools=>refresh_snapshot_for_cr( 59 EXPORTING 60 iv_change_request = ls_crequest-usmd_crequest 61 IMPORTING 62 et_message = et_message 63 ev_failed = ev_failed ). 64 65 ENDIF. 66 67 68ENDMETHOD.

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

Related questions and keywords

Alternative questions

  • How can I find the active MDG change request for a Business Partner and refresh it?
  • Which ABAP APIs are used to refresh a Business Partner change request in SAP MDG?
  • How do I reinitialize the MDG context and refresh the snapshot for a BP change request?

Possible questions

  • How do I refresh an SAP MDG Business Partner change request snapshot in ABAP when I already know the BP number?
  • Which class and method are used to retrieve the active change request for BP_HEADER?
  • How do I initialize the MDG app context before calling snapshot refresh?
  • What is the ABAP pattern to refresh an active MDG Business Partner change request?
  • How do I add a note to a change request after refresh?

Keywords

SAP MDGBusiness Partnerchange requestsnapshot refreshCL_USMD_CREQUEST_APICL_USMD_APP_CONTEXTCL_USMD_SNAPSHOT_TOOLSBP_HEADERUSMD_TS_VALUEUSMD_SNAPSHOT