SAP MDG · REPLICATION INBOUND
How do I implement profit center key mapping in MDG Finance outbound replication using `USMD_SE_PC_RPLCTN_EX`?
Implement the custom BAdI class `ZCL_PROFIT_CENTER_KEYMAP` under enhancement `USMD_SE_PC_RPLCTN_EX`. In `IF_EX_USMD_PC_RPLCTN~OUTBOUND_PROCESSING`, read `CS_PROXY_DATA`, check `TVARVC` entry `ZMDG_PC_KEY_MAPPING` for the destination system, rewrite the first four characters of the profit center ID when active, and write the adjusted table back unchanged otherwise.
Implement the custom BAdI class `ZCL_PROFIT_CENTER_KEYMAP` under enhancement `USMD_SE_PC_RPLCTN_EX`. In `IF_EX_USMD_PC_RPLCTN~OUTBOUND_PROCESSING`, read `CS_PROXY_DATA`, check `TVARVC` entry `ZMDG_PC_KEY_MAPPING` for the destination system, rewrite the first four characters of the profit center ID when active, and write the adjusted table back unchanged otherwise.
`ZCL_PROFIT_CENTER_KEYMAP` is a custom MDG Finance key-mapping enhancement for profit center replication. It runs in `USMD_SE_PC_RPLCTN_EX`, reads the outbound bulk request from `CS_PROXY_DATA`, checks whether mapping is active for the target system via `TVARVC` entry `ZMDG_PC_KEY_MAPPING`, and then rewrites the first four characters of the profit center ID before handing the payload back to standard replication flow.
Process flow
- Create or activate BAdI implementation `
USMD_SE_PC_RPLCTN_EX` for profit center replication. - Implement `IF_EX_USMD_PC_RPLCTN~OUTBOUND_PROCESSING` in `ZCL_PROFIT_CENTER_KEYMAP`.
- Load `cs_proxy_data-profit_centre_replication_bulk-profit_centre_replication_requ` into a local table.
- Read `TVARVC` entry `ZMDG_PC_KEY_MAPPING` using `i_dis_system`.
- If a mapping row exists, loop through the profit center replication messages.
- Rewrite `profit_centre-id+0(4)` when it equals `0002`.
- Modify the local message table and write it back to `CS_PROXY_DATA`.
- Keep `CT_MESSAGE` unchanged unless you add application messages or logging.
Referenced tables
| Object | Purpose |
|---|---|
TVARVC | Stores the configuration switch `ZMDG_PC_KEY_MAPPING` used to activate mapping for the target destination system. |
MDGF_PRFT_CTR_RPLCTN_REQ_M_TAB | Internal table type used for the outbound profit center replication messages. |
MDGF_PRFT_CTR_RPLCTN_REQ_MSG | Single outbound profit center replication message structure. |
ILLUSTRATIVE ABAP SAMPLE
Source ABAP example: ZCL_PROFIT_CENTER_KEYMAP_FULL.abap
Exact relevant implementation excerpt from the knowledge document set.
1class ZCL_PROFIT_CENTER_KEYMAP definition
2 public
3 final
4 create public .
5
6public section.
7*"* public components of class CL_USMD_SE_PC_RPLCTN_BADI
8*"* do not include other source files here!!!
9
10 interfaces IF_BADI_INTERFACE .
11 interfaces IF_EX_USMD_PC_RPLCTN .
12protected section.
13*"* protected components of class CL_USMD_SE_PC_RPLCTN_BADI
14*"* do not include other source files here!!!
15private section.
16*"* private components of class CL_USMD_SE_PC_RPLCTN_BADI
17*"* do not include other source files here!!!
18ENDCLASS.
19
20
21
22CLASS ZCL_PROFIT_CENTER_KEYMAP IMPLEMENTATION.
23
24
25method IF_EX_USMD_PC_RPLCTN~INBOUND_PROCESSING.
26*
27* Method can be used for redefinition (or enhancement) of the incoming processing status data that belongs to a corresponding
28* replication request message for profit centre (confirmation message is sent back to MDGF).
29*
30* In case of an active BAdI implementation, this method would be called during inbound processing from standard service
31* implementation class CL_USMD_CO_PC_IN, method MAPPING_IN.
32*--------------------------------------------------------------------------------------------------------------------
33
34
35 data:
36 lt_log_item type mdgf_log_item_tab,
37 ls_log_item type mdgf_log_item,
38 lt_message type usmd_t_message,
39 ls_message type usmd_s_message,
40 ls_message_header type mdgf_business_document_messag3.
41
42
43
44* Get processing result code of original replication request message (will be used for status update in MDGF)
45 cs_data-usmd_resultcode = is_proxy_data-log-business_document_processing_r(1).
46
47* Get target system of original replication request message (will be used for status update)
48 cs_data-usmd_dis_system = is_proxy_data-message_header-sender_business_system_id.
49
50* Message header includes message GUIDs (will be also used for status update)
51 ls_message_header = is_proxy_data-message_header.
52
53
54* Inbound conversion of message GUIDs:
55 try.
56 call method cl_gdt_conversion=>guid_inbound
57 exporting
58 im_value = ls_message_header-reference_uuid-content
59 importing
60 ex_guid_c = cs_data-usmd_msg_rqguid.
61
62 catch cx_gdt_conversion. "#EC NO_HANDLER
63
64 endtry.
65
66 try.
67 call method cl_gdt_conversion=>guid_inbound
68 exporting
69 im_value = ls_message_header-uuid-content
70 importing
71 ex_guid_c = cs_data-usmd_msg_coguid.
72
73 catch cx_gdt_conversion. "#EC NO_HANDLER
74
75 endtry.
76
77
78* analyze messages (to be stored in application log)
79 lt_log_item = is_proxy_data-log-item.
80
81* conversion of lt_log_item into message table of cs_data (type: BAPIRET2_TAB)
82 lt_message = ct_message.
83 loop at lt_log_item into ls_log_item.
84 if 1 = 2.
85* for finding message usage
86 message i010(usmd_xi_proxy) with space space space space.
87 endif.
88
89 clear ls_message.
90 case ls_log_item-severity_code.
91 when '3'. ls_message-msgty = 'E'.
92 when '2'. ls_message-msgty = 'W'.
93 when '1'. ls_message-msgty = 'I'.
94 endcase.
95 ls_message-msgid = 'USMD_XI_PROXY'.
96 ls_message-msgno = '010'.
97 ls_message-msgv1 = ls_log_item-note.
98 insert ls_message into table lt_message.
99 endloop.
100
101 ct_message = lt_message.
102
103
104endmethod.
105
106
107METHOD if_ex_usmd_pc_rplctn~outbound_processing.
108*
109* Method for redefinition/enhancement or creation of message data for outbound replication bulk request of
110* Profit center (in CS_PROXY_DATA which contains the bulk message).
111*
112* In case that method is called with initial CS_PROXY_DATA, it can be also used for message creation from scratch (by analysis
113* of the importing parameters). This would be necessary, if no SMT-Mapping is available that transforms the selected
114* MDGF data (in IT_DATA) into the message type data (CS_PROXY_DATA).
115*
116* In case of an active BAdI implementation, this method would be called during outbound processing from standard service implementation
117* class CL_USMD_RQ_PC_OUT, method IF_DRF_OUTBOUND~SEND_MESSAGE.
118*--------------------------------------------------------------------------------------------------------------------
119*&---------------------------------------------------------------------*
120*& Class : ZCL_PROFIT_CENTER_KEYMAPThe remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- How can I rewrite the profit center ID during MDG Finance replication?
- What is the BAdI for profit center key mapping in MDG Finance?
- How do I use TVARVC to control profit center key mapping in outbound replication?
Possible questions
- What is `ZCL_PROFIT_CENTER_KEYMAP` used for?
- Which BAdI method updates profit center outbound payloads?
- How does TVARVC control profit center key mapping?
- What part of the profit center ID is rewritten in the sample?
- How is inbound confirmation handled in the same BAdI implementation?