SAP MDG · REPLICATION OUTBOUND
How do I implement a generic outbound proxy pattern in SAP MDG/ABAP for business partner data?
Use a working copy of the input, normalize values, fill the generated nested proxy structure, call the proxy class, and convert `cx_ai_system_fault` into a readable message. The sample report `ZSAM_TEST`-style pattern is suitable for manual validation of the outbound payload.
Use a working copy of the input, normalize values, fill the generated nested proxy structure, call the proxy class, and convert `cx_ai_system_fault` into a readable message. The sample report `ZSAM_TEST`-style pattern is suitable for manual validation of the outbound payload.
This pattern is a simple ABAP outbound proxy flow for SAP MDG/business partner replication: copy the incoming values into local variables, normalize them, map them into the generated nested request structure, call the generated proxy class, and translate technical faults into a user-readable message. The sample below uses a report-style test harness, which is a practical way to validate the payload assembly before integrating it into a business process.
Process flow
- Copy incoming values into local variables.
- Normalize name or key fields as required by the target system.
- Populate the nested request structure field by field.
- Instantiate the generated proxy class.
- Call the proxy method with the populated input structure.
- Catch `cx_ai_system_fault` and convert the text into a readable message.
- Write the final status or log entry if the process needs traceability.
ILLUSTRATIVE ABAP SAMPLE
Source ABAP example
Exact relevant implementation excerpt from the knowledge document.
1"==============================================================================
2" Generic Outbound Proxy Sample
3" Purpose:
4" - Show the common pattern for preparing data, filling generated proxy
5" structures, calling the proxy, and handling technical faults.
6" Flow:
7" - Collect source values
8" - Normalize the values
9" - Fill the nested request structure
10" - Create the proxy instance
11" - Call the proxy method
12" - Convert technical failures into a readable return message
13"==============================================================================
14
15REPORT zsam_outbound_proxy_sample.
16
17PARAMETERS:
18 p_partner TYPE kunnr,
19 p_reqid TYPE char3,
20 p_country TYPE land1,
21 p_name1 TYPE name1_gp,
22 p_name2 TYPE name2_gp.
23
24DATA:
25 ls_request TYPE zmt_partner_transfer_gts_req,
26 ls_response TYPE zmt_partner_transfer_gts_res,
27 lo_proxy TYPE REF TO zco_si_partner_transfer_gts_in,
28 lv_message TYPE string.
29
30START-OF-SELECTION.
31
32 " Keep the input in local working variables so the mapping is explicit.
33 DATA(lv_partner) = p_partner.
34 DATA(lv_reqid) = p_reqid.
35 DATA(lv_country) = p_country.
36 DATA(lv_name1) = p_name1.
37 DATA(lv_name2) = p_name2.
38
39 " Normalize the values that the receiver expects in a stable format.
40 TRANSLATE lv_name1 TO UPPER CASE.
41 TRANSLATE lv_name2 TO UPPER CASE.
42
43 " Fill the generated proxy structure step by step.
44 ls_request-mt_partner_transfer_gts_req-partner_inbound_gts-partner-partner_key-partner_id = lv_partner.
45 ls_request-mt_partner_transfer_gts_req-partner_inbound_gts-partner-partner_key-partner_typ = '02'.
46 ls_request-mt_partner_transfer_gts_req-partner_inbound_gts-partner-partner_head-extern_no = lv_partner.
47 ls_request-mt_partner_transfer_gts_req-partner_inbound_gts-partner-partner_head-partn_cat = '2'.
48 ls_request-mt_partner_transfer_gts_req-partner_inbound_gts-partner-central-partnerexternal = lv_partner.
49 ls_request-mt_partner_transfer_gts_req-partner_inbound_gts-partner-central_org-name1 = lv_name1.
50 ls_request-mt_partner_transfer_gts_req-partner_inbound_gts-partner-central_org-name2 = lv_name2.
51 ls_request-mt_partner_transfer_gts_req-partner_inbound_gts-partner-partner_address-country = lv_country.
52 ls_request-mt_partner_transfer_gts_req-partner_inbound_gts-partner-iv_upd_task_pntbp = abap_false.
53
54 " Add any additional business controls or derived values here.
55 IF lv_reqid IS NOT INITIAL.
56 ls_request-mt_partner_transfer_gts_req-partner_inbound_gts-partner-partner_key-org_logsystem = sy-sysid.
57 ENDIF.
58
59 TRY.
60 " Create the proxy object and send the payload.
61 CREATE OBJECT lo_proxy.
62 lo_proxy->si_partner_transfer_gts_inboun(
63 EXPORTING
64 input = ls_request
65 IMPORTING
66 output = ls_response ).
67
68 lv_message = |Proxy call completed successfully for partner { lv_partner }|.
69
70 CATCH cx_ai_system_fault INTO DATA(lx_system_fault).
71 " Convert the technical error into a readable message for the caller.
72 lv_message = lx_system_fault->get_text( ).
73 ENDTRY.
74
75 " Display the final status for the test harness.
76 WRITE: / lv_message.The remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- How do I prepare, map, and send an outbound SAP proxy request from ABAP?
- How do I handle technical faults in an MDG outbound proxy report?
- How do I build a test report for a generated outbound proxy in ABAP?
Possible questions
- How do I implement a generic outbound proxy pattern in SAP MDG/ABAP for business partner data?
- How do I prepare, map, and send an outbound SAP proxy request from ABAP?
- How do I handle technical faults in an MDG outbound proxy report?
- How do I build a test report for a generated outbound proxy in ABAP?
- Which fields are mapped in the sample outbound proxy?
- What exception should be caught for the proxy call?