on ‎2018 Feb 07 6:23 PM - last edited on ‎2024 Feb 04 4:18 AM by postmig_api_4
Our overarching goal is to integrate SAP Hybris Commerce v6.4 with SAP S/4HANA ERP for both master & transactional data. I am currently working on replicating B2C Customers from SAP Hybris Commerce to SAP S/4HANA ERP via Data Hub.
We have a requirement to utilize a segment of DEBMAS07 that is not natively provided in the Data Hub sapcustomer-target extension as a Target Item. The data required to populate the value of this segment is already available within the Canonical Item CanonicalParty, which is originally sources from the Raw Item RawHybrisCustomer. The mechanism / transformation declarations for these items are already present within the sapcustomer-canonical and sapcustomer-raw Data Hub extensions, respectively.
In order to add the new Target Item to the outbound DEBMAS07 iDoc, I have completed the following:
Generated a new Data Hub extension via the Data Hub extension Maven archetype provided by the SAP Hybris Data Hub Solution Book. I called this extension zsapcustomer-target, and renamed the outbound iDoc to ZDEBMAS.
Successfully copied the Target Item declarations present within the sapcustomer-target extension, and declared dependencies on other Data Hub extensions (such as sapcustomer-canonical) as needed. Confirmed that the new custom iDoc (ZDEBMAS) that overwrites DEBMAS07 is exported successfully from Data Hub.
Within this new zsapcustomer-target extension, I would like to add support for populating the ZDEBMAS$E1KNA1M$E1KNB1M$SMTP_ADDR segment with the partyId attribute from CanonicalParty. I have added the following Target Item to zsapcustomer-target-datahub-extension.xml
ZDEBMAS$E1KNA1M$E1KNB1M
<exportCode>idockeyfield=KUNNR|sendorder=50</exportCode>
<description>subsegment E1KNB1M of Header segment</description>
<canonicalItemSource>CanonicalParty</canonicalItemSource>
<attributes>
<attribute>
<name>SMTP_ADDR</name>
<transformationExpression>resolve('CanonicalParty').partyId</transformationExpression>
<exportCode>keyfield=true</exportCode>
</attribute>
</attributes>
</item>
Upon adding this Target Item, the extension source code compiles & packages successfully (via mvn clean package). Additionally, the Data Hub server starts successfully without displaying any errors. However, upon triggering a B2C customer replication event from SAP Hybris Commerce, Data Hub fails to transform Canonical Items to Target Items. The following error is displayed in the Data Hub server console logs:
com.hybris.datahub.model.InvalidAttributeException: Field : KUNNR is not defined for type : ZDEBMAS$E1KNA1M$E1KNB1M and cannot be retrieved
I have reviewed the official SAP Hybris Help documentation regarding idockeyfield and exportCode tags that should be declared for Target Items that map to iDoc Segments: https://help.hybris.com/6.4.0/hcd/ea217cb9b7214f3181466d4c60389f8f.html. I am also running my Data Hub instance with the property datahub.autoInitMode=create-drop, allowing changes in declared Items to be properly persisted in the Data Hub database after each server restart.
I'm confused by this error, and fundamentally don't understand why this error is being thrown. Is it related to the idockeyfield or exportCode tags? If so, what would be appropriate values for these tags? Why?
Request clarification before answering.
looking at your question i feel you are mising
<attribute>
<name>KUNNR</name>
<localizable>false</localizable>
<collection>false</collection>
<transformationExpression>resolve('CanonicalParty').partyId</transformationExpression>
<exportCode></exportCode>
<mandatoryInHeader>true</mandatoryInHeader>
</attribute>
as you have mentioned KUNNR as keyfield for idoc. it's necessary to mention KUNNR in all segments you are populating so that relation with other Segments from same idoc are maintained.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes - I agree with your assessment. However, KUNNR is not a valid field for E1KNA1M$E1KNB1M within the DEBMAS07 XSD schema. I'm struggling with understanding how we can define a idockeyfield within exportCode when the segment populated as values within these fields is not supported by the schema. Is there a mechanism to filter out this particular segment from the iDoc prior to publication to the target system?
For due diligence, I have added the attribute to the Target Item as suggested. The following error results (Data Hub server logs):
[DEBUG] [c.h.d.r.j.i.DefaultTargetItemJpaRepository] Found 1 ZDEBMAS$EDI_DC40 items...
[ERROR] [c.h.d.s.i.PublicationActionHandler] Error publishing action: 1 java.lang.NullPointerException: null at com.hybris.datahub.sapidocoutboundadapter.impl.DefaultIDocOutboundAdapter.setStringIfNull(DefaultIDocOutboundAdapter.java:569) ~[sapidocoutboundadapter-6.4.0.0-RC2.jar:na]
<item>
<type>ORDERS01$EDI_DC40</type>
<exportCode>idockeyfield=ID</exportCode>
<description>IDoc Control Header segment</description>
<updatable>true</updatable>
<canonicalItemSource>CanonicalOrder</canonicalItemSource>
<status>ACTIVE</status>
<attributes>
<attribute>
<name>ID</name>
<localizable>false</localizable>
<collection>false</collection>
<transformationExpression>orderId</transformationExpression>
<exportCode></exportCode>
<mandatoryInHeader>true</mandatoryInHeader>
</attribute>
</attributes>
</item>
i have created a new attribute as ID which has orderId in ORDERS01$EDI_DC40, i have used same ID attribute in all other segments. This field will help you holding all segments of same idoc together.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.