SAP MDG · UTILITIES
How does the MDG Business Partner GTS interface build and send partner transfer data from a change request?
The interface reads the active MDG Business Partner change request, derives the process/step/type, collects BP header, central, and address data, builds the GTS partner transfer payload, calls the generated proxy, and writes a log entry with the request/response XML and status.
The interface reads the active MDG Business Partner change request, derives the process/step/type, collects BP header, central, and address data, builds the GTS partner transfer payload, calls the generated proxy, and writes a log entry with the request/response XML and status.
This MDG BP utility method builds a GTS outbound payload directly from the Business Partner change request. It determines the CR process and step, reads BP_HEADER, BP_CENTRL, and AD_POSTAL data from the BP model, derives partner type and key, then calls the generated GTS proxy and records the request/response in a custom log table.
Process flow
- 1. Get the current MDG change-request context from `CL_USMD_APP_CONTEXT` or derive it from `USMD120C` and `USMD1601`.
- 2. Restrict processing to the supported workflows `SUP1`, `SUP2`, `CUP1`, `CUP2`, `CUP6`, and `SUP6`.
- 3. Determine partner type and partner role based on supplier vs. customer flow.
- 4. Create the change-request API instance with `CL_USMD_CREQUEST_API=>get_instance`.
- 5. Create the model instance for model `BP` with `CL_USMD_MODEL_EXT=>get_instance`.
- 6. Read the change-request entity keys using `read_char_value` on `crequest`.
- 7. Read `BP_HEADER`, `BP_CENTRL`, and `AD_POSTAL` with `read_value`.
- 8. Derive BP, customer, vendor, and address numbers where required using `BUT000`, `CVI_VEND_LINK`, `CVI_CUST_LINK`, and `BUT020`.
Application context / MDG runtime context via `CL_USMD_APP_CONTEXT`
Obtain current change request process, step, and type when the method is called inside MDG workflow.
Fallback read from `USMD120C` joined with `USMD1601`
Derive CR type and process when no application context is available.
Logical system derivation with `OWN_LOGICAL_SYSTEM_GET`
Populate `org_logsystem` in the GTS partner key.
Custom logging table `ZMDG_BP_GTS_LOG`
Store request/response XML and execution status for audit and troubleshooting.
Referenced tables
| Object | Purpose |
|---|---|
USMD120C | Change-request type lookup used when application context is not available. |
USMD1601 | Maps change-request type to MDG process. |
BUT000 | Provides BP partner GUID mapping used to resolve customer/vendor numbers. |
CVI_VEND_LINK | Resolves BP partner GUID to vendor number for supplier flows. |
CVI_CUST_LINK | Resolves BP partner GUID to customer number for customer flows. |
BUT020 | Resolves partner to address number. |
ZMDG_BP_GTS_LOG | Custom log table for GTS request/response tracking. |
ILLUSTRATIVE ABAP SAMPLE
Source ABAP example
Exact relevant implementation excerpt from the knowledge document.
1METHOD call_gts_interface.
2 CONSTANTS: lc_model TYPE usmd_model VALUE 'BP'.
3 DATA : lo_o_gts_proxy TYPE REF TO zco_si_partner_transfer_gts_in,
4 ls_input TYPE zmt_partner_transfer_gts_req,
5 ls_partner_inbound TYPE zdt_partner_transfer_gts_req_1,
6 ls_partner TYPE zdt_partner_transfer_gts_req_5,
7 ls_partner_key TYPE zdt_partner_transfer_gts_req_p,
8 ls_partner_head TYPE zdt_partner_transfer_gts_req_2,
9 ls_central TYPE zdt_partner_transfer_gts_req_6,
10 ls_central_org TYPE zdt_partner_transfer_gts_req_c,
11 ls_partner_address TYPE zdt_partner_transfer_gts_req_3,
12 ls_partner_ad1vl TYPE zdt_partner_transfer_gts_req_4,
13 lv_c_cr_num TYPE char12,
14 lo_crequest TYPE REF TO if_usmd_crequest_api,
15 lo_model TYPE REF TO if_usmd_model_ext,
16 lt_entity_data TYPE usmd_ts_entity_data_all,
17 lt_entities TYPE usmd_t_crequest_entity,
18 lt_entity_bp_header TYPE TABLE OF /mdgbp/_s_bp_pp_bp_header,
19 lt_entity_bp_centrl TYPE TABLE OF /mdgbp/_s_bp_pp_bp_centrl,
20 lt_entity_ad_postal TYPE TABLE OF /mdgbp/_s_bp_pp_ad_postal,
21 ls_entity_bp_centrl TYPE /mdgbp/_s_bp_pp_bp_centrl,
22 ls_entity_bp_header TYPE /mdgbp/_s_bp_pp_bp_header,
23 ls_entity_ad_postal TYPE /mdgbp/_s_bp_pp_ad_postal,
24 ls_message TYPE usmd_s_message,
25 lv_entity_name TYPE usmd_fieldname,
26 lt_sel TYPE usmd_ts_sel,
27 lv_partner TYPE bu_partner,
28 lv_partner_typ TYPE string,
29 lv_logsys TYPE logsys,
30 ls_sel TYPE usmd_s_sel,
31 ls_log_table TYPE zmdg_bp_gts_log,
32 lt_log_table TYPE TABLE OF zmdg_bp_gts_log,
33 lv_cr_p TYPE usmd_process,
34 lv_cr_step TYPE usmd_crequest_appstep,
35 lv_cr_type TYPE usmd_crequest_type,
36 lv_input_xml TYPE string,
37 lv_output_xml TYPE string.
38
39
40 DATA(lo_app_context) = cl_usmd_app_context=>get_context( ).
41 IF lo_app_context IS BOUND.
42* DATA(ls_crequest) = lo_app_context->mv_crequest_id.
43 lv_cr_p = lo_app_context->mv_process.
44 lv_cr_step = lo_app_context->mv_crequest_step.
45 lv_cr_type = lo_app_context->mv_crequest_type.
46 ELSE.
47 SELECT SINGLE cr~usmd_creq_type, p~usmd_process INTO ( @lv_cr_type, @lv_cr_p ) FROM usmd120c AS cr
48 INNER JOIN usmd1601 AS p ON cr~usmd_creq_type = p~usmd_creq_type
49 WHERE usmd_crequest = @iv_cr_number. "#EC CI_BUFFJOIN
50 CHECK sy-subrc = 0.
51 IF lv_cr_p = 'SUP1' OR lv_cr_p = 'CUP1'.
52 lv_cr_step = '00'.
53 ENDIF.
54 ENDIF.
55
56
57 CHECK lv_cr_p = 'SUP1' OR
58 lv_cr_p = 'SUP2' OR
59 lv_cr_p = 'CUP1' OR
60 lv_cr_p = 'CUP2' OR
61 lv_cr_p = 'CUP6' OR
62 lv_cr_p = 'SUP6'.
63
64 IF lv_cr_p = 'SUP1' OR lv_cr_p = 'SUP2' OR lv_cr_p = 'SUP6'.
65 lv_partner_typ = '01'.
66 ls_partner_head-partnerrole = 'SLLCPS'.
67 ELSEIF lv_cr_p = 'CUP1' OR lv_cr_p = 'CUP2' OR lv_cr_p = 'CUP6'.
68 lv_partner_typ = '02'.
69 ls_partner_head-partnerrole = 'SLLCPC'.
70 ENDIF.
71 CALL METHOD cl_usmd_crequest_api=>get_instance
72 EXPORTING
73 iv_crequest = iv_cr_number
74 IMPORTING
75 re_inst_crequest_api = lo_crequest.
76
77 "Get read-only access to model data
78 CALL METHOD cl_usmd_model_ext=>get_instance
79 EXPORTING
80 i_usmd_model = lc_model
81 IMPORTING
82 eo_instance = lo_model.
83 CHECK lo_crequest IS BOUND AND lo_model IS BOUND.
84* prepare selection
85 ls_sel-sign = usmd0_cs_ra-sign_i.
86 ls_sel-option = usmd0_cs_ra-option_eq.
87 ls_sel-fieldname = usmd0_cs_fld-crequest.
88 ls_sel-low = iv_cr_number.
89 INSERT ls_sel INTO TABLE lt_sel.
90 CALL METHOD lo_model->read_char_value
91 EXPORTING
92 i_fieldname = usmd0_cs_fld-crequest
93 it_sel = VALUE usmd_ts_sel( ( sign = 'I' option = 'EQ' fieldname = usmd0_cs_fld-crequest low = iv_cr_number ) ) "lt_sel
94 IMPORTING
95 et_data = lt_entities.
96
97 LOOP AT lt_entities ASSIGNING FIELD-SYMBOL(<fs_entity>)
98 WHERE usmd_seqnr = '1' OR usmd_seqnr = '2'. "#EC CI_SORTSEQ
99 ls_sel-fieldname = <fs_entity>-usmd_entity_obj.
100 ls_sel-low = <fs_entity>-usmd_value.
101 INSERT ls_sel INTO TABLE lt_sel.
102 IF <fs_entity>-usmd_entity_obj = 'BP_HEADER'
103 AND <fs_entity>-usmd_seqnr = '1'.
104 lv_partner = <fs_entity>-usmd_value.
105 DATA(lv_bp) = lv_partner.
106 IF lv_cr_p EQ 'SUP2' OR lv_cr_p EQ 'SUP6'.
107 SELECT SINGLE vendor FROM cvi_vend_link AS v
108 INNER JOIN but000 AS bu ON v~partner_guid = bu~partner_guid
109 WHERE bu~partner = @lv_partner
110 INTO @DATA(lv_vendor).
111 IF sy-subrc = 0.
112 lv_partner = lv_vendor.
113 ENDIF.
114
115 ELSEIF lv_cr_p EQ 'CUP2' OR lv_cr_p EQ 'CUP6'.
116 SELECT SINGLE customer FROM cvi_cust_link AS c
117 INNER JOIN but000 AS bu ON c~partner_guid = bu~partner_guid
118 WHERE bu~partner = @lv_partner
119 INTO @DATA(lv_customer).
120 IF sy-subrc = 0.The remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- How do I implement a Business Partner GTS outbound interface from MDG change request data?
- Which MDG APIs are used to read BP change request data for GTS transfer?
- How is partner type and partner key determined before calling the GTS proxy?
Possible questions
- How do I implement a Business Partner GTS outbound interface from MDG change request data?
- Which MDG APIs are used to read BP change request data for GTS transfer?
- How is partner type and partner key determined before calling the GTS proxy?
- How are the BP_HEADER, BP_CENTRL, and AD_POSTAL entities read from a change request?
- How is the generated GTS proxy called and retried on error?