This article discusses a strategy for preventing the unintended deletion of reduced XML payloads.
When reduced XML payloads are received from third-party systems like PTC, PDM, Salesforce, etc. SAP's standard behavior is to replace the existing target data objects with the incoming payload content. This means that any fields not included in the reduced payload could be unintentionally deleted in the target data object. This is because SAP interprets the absence of certain fields in the incoming data as an instruction to clear those fields in the existing data object.
Remark: The presence of middleware, such as SAP PI/PO, Seeburger, Jitterbit, etc., between third-party systems and SAP systems, plays a critical role in managing system integration; especially when dealing with different data model structures between the sender and receiving systems.
To mitigate this risk, it's crucial to implement certain strategies. Our strategy here in this particular case is pre-processing. Before processing the incoming XML payload, perform a pre-check to compare it with the currently active data object and decide which fields should be updated and which ones should be preserved.
For your purpose, where product data is being replicated using SAP's standard service provider ProductMDMBulkReplicateRequest_In, handling reduced XML payloads becomes even more critical. This service is designed to handle bulk replication of product data, and it’s essential to ensure that the received payloads are complete enough to maintain data integrity in SAP.
When replication involves these third-party systems, the reduced or altered data payloads can lead to unintended consequences, such as missing or incomplete updates in SAP. This is especially critical when the third-party system's data model does not fully align with SAP’s, or when not all data from the third-party system is available or transmitted during replication.
Some key points to consider when integrating a third-party system with SAP:
Remark: When third-party systems send reduced XML payloads, which might omit certain fields, SAP may interpret these omissions as an instruction to delete or clear those fields. To prevent unintended data loss, it’s important to develop strategies to recognize and handle these cases, ensuring that only the intended updates are made.
Here is an example of a reduced XML payload that might be received from a third-party system:
Figure 1 – An example of reduced XML payload received from a third-party system
More detailed information about the ProductMDMBulkReplicateRequest_In service and the corresponding product data structure in SAP S/4HANA can be found on the official SAP Help Portal.
When a third-party payload omits certain fields that are already populated in SAP, the SAP system may interpret these missing fields as blank or null during the inbound processing. This can result in previously enriched fields in SAP being overwritten and set to empty if they aren't included in the incoming payload. This behavior underscores the importance of ensuring that critical fields are always included in the payload or implementing logic to preserve existing data in SAP when certain fields are absent.
To address the issue of missing fields in third-party payloads leading to overwriting of populated fields in SAP, a Business Add-In (BAdI) can be implemented during inbound processing. Our applied custom logic in this BAdI ensures that fields already populated in SAP are not overwritten with null values if the corresponding fields are absent in the third-party payload. This solution helps maintain data integrity by preserving existing values in SAP when certain fields are not provided in the incoming data.
This article presents a possible solution to address missing data in the incoming payload by using the BAdI MDM_SE_PRD_BULK_REP_REQ. The idea is to detect differences between the active data in SAP and the incoming payload, ensuring that any field missing in the reduced payload is properly identified and managed.
Here are some nice-to-have skills and knowledge areas for handling this topic:
ABAP programming, T-code: SRT_MONI, Web Services, End-to-End Data Process Flow, XML/XSD, SAP Integration.
Our idea is to dynamically identify all active fields within the Material Data Model in SAP during inbound processing that are not managed by the third-party system but are populated in the SAP system. We use BAdI MDM_SE_PRD_BULK_REP_REQ for this purpose.
For our solution, we pursued the following steps:
Signature of IF_MDM_SE_PRD_BULK_REP_REQ~INBOUND_PROCESSING:
Figure 2 – Signature of method: IF_MDM_SE_PRD_BULK_REP_REQ~INBOUND_PROCESSING
The code for method IF_MDM_SE_PRD_BULK_REP_REQ~INBOUND_PROCESSING is like this:
METHOD if_mdm_se_prd_bulk_rep_req~inbound_processing.
DATA lv_matnr TYPE matnr.
lv_matnr = in-product-receiver_product_internal_id.
me->fill_from_mara(
EXPORTING
iv_matnr = lv_matnr " Material Number
CHANGING
cs_out = out ). " Product Replication Services Structure
COMMIT WORK.
ENDMETHOD.
Signature of FILL_FROM_MARA:
Figure 3 – Signature of method: FILL_FROM_MARA
The code for method FILL_FROM_MARA is like this:
METHOD fill_from_mara.
FIELD-SYMBOLS:
<lv_out> TYPE any,
<lv_active> TYPE any,
<lv_out_x> TYPE any.
" select the active MARA data
SELECT SINGLE * FROM mara
INTO (ls_mara)
WHERE matnr = _matnr .
" check if it is a change scenario, then process
IF sy-subrc NE 0.
RETURN.
ENDIF.
" get the fields which are not empty from MARA result str
cl_abap_struct_utilities=>filled_components(
EXPORTING
struct = ls_mara
RECEIVING
filled_comps = DATA(lt_filled_comps) ).
" assign the related OUT parameters to field symbols
READ TABLE cs_out-product-mara_tab ASSIGNING FIELD SYMBOL(<ls_mara_out>) INDEX 1.
READ TABLE cs_out-product-mara_x_tab ASSIGNING FIELD-SYMBOL(<ls_mara_x_out>) INDEX 1.
" if related field symbols are not assigned then exit the method
IF <ls_mara_out> IS ASSIGNED AND
<ls_mara_x_out> IS ASSIGNED.
" loop at filled info of MARA fields
LOOP AT lt_filled_comps ASSIGNING FIELD-SYMBOL(<ls_filled_comps>).
UNASSIGN <lv_out>.
UNASSIGN <lv_active>.
UNASSIGN <lv_out_x>.
" assign the field not empty in MARA, for OUT parameter
ASSIGN COMPONENT <ls_filled_comps>-name OF STRUCTURE <ls_mara_out> TO <lv_out>.
" if related out field is already have a value, continue. Otherwise take an action
IF <lv_out> IS ASSIGNED AND <lv_out> IS INITIAL.
" assign the related fields value of MARA result
ASSIGN COMPONENT <ls_filled_comps>-name OF STRUCTURE ls_mara TO <lv_active>.
" if the field has a value in MARA (it has a value because of the loop logic), give it to OUT parameter
IF <lv_active> IS ASSIGNED AND
<lv_active> IS NOT INITIAL.
" need to set update flag
ASSIGN COMPONENT <ls_filled_comps>-name OF STRUCTURE <ls_mara_x_out> TO <lv_out_x>.
" only update values which has update flag
IF <lv_out_x> IS ASSIGNED.
<lv_out> = <lv_active>.
<lv_out_x> = abap_true.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
ENDMETHOD.
Integrating third-party applications with SAP can lead to challenges when the payloads are reduced, causing SAP to treat missing fields as blanks or nulls. To address this, we've implemented an inbound BAdI solution that detects and populates missing fields within the XML payload. This approach helps solving the issue of the deletion of populated fields in SAP.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
3 | |
3 | |
2 | |
2 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 |