cancel
Showing results for 
Search instead for 
Did you mean: 

DEBMAS partner role list to hybris company / b2bunit

kneuhaus
Explorer
0 Kudos
192

Hi Folks,

we already have custom extensions in our datahub-project (currently on SAP Commerce 1905), where we added/modified some attributes of some types. we receive (DEBMAS) idocs,transform them based on sapproduct and sapcustomer-extensions of datahub.


Now we want to attach all partnerroles from debmas to it's B2BUnit in SAP Commerce. As first solution we declared a many2many-relation in hybris (PartnerRole - B2BUnit) and created an impex based on a custom canoical relation object, a custom canonical "partnerRole" object with all it's attributes and the existing B2BUnit CanonicalPartySales.

This is not the right way as it is a one2many relation by design. It works 1 time only, creating these relations, updating fails on the hybris side, maybe we could ignore this. But it's not the right way.

We're stuck to create a "datahub" relation internally to have this as a collection-attribute in the B2Bunit like "groups" - like a real updateable 1-many-relation - is this the way it should go ?

Should the "collection" on a canonical-Item be used and how should the canonical items be related (primary-key, foreign key) ?
If anyone have some advice ?

Here's some data:

DEBMAS-PartnerRole-Section:

E1KNA1M-E1KNVVM->[...]        <E1KNVPM SEGMENT="1">
          <MSGFN>005</MSGFN>
          <PARVW>AG</PARVW>
          <KUNN2>0010000123</KUNN2>
          <PARZA>000</PARZA>
        </E1KNVPM>
        <E1KNVPM SEGMENT="1">
          <MSGFN>005</MSGFN>
          <PARVW>RG</PARVW>
          <KUNN2>0010000123</KUNN2>
          <PARZA>000</PARZA>
        </E1KNVPM>


Canonical-custom-extension:

<item>
<type>CanonicalCustomPartnerRole</type>
<documentId>partyId</documentId>
<attributes>
<attribute>
<model>
<localizable>false</localizable>
<collection>false</collection>
<type>String</type>
<primaryKey>true</primaryKey>
</model>
<name>partyId</name>
<transformations>
<transformation>
<rawSource>RawDEBMAS</rawSource>
<expression spel="true">#this?.getField('E1KNA1M-KUNNR') + '_KNA1'</expression>
</transformation>
</transformations>
</attribute>
<attribute>
<name>salesKey</name>
<model>
<localizable>false</localizable>
<collection>false</collection>
<type>String</type>
<primaryKey>true</primaryKey>
</model>
<transformations>
<transformation>
<rawSource>RawDEBMAS</rawSource>
<expression spel="true">#root.getField('E1KNA1M-E1KNVVM-VKORG')+'_'+#root.getField('E1KNA1M-E1KNVVM-VTWEG')+'_'+#root.getField('E1KNA1M-E1KNVVM-SPART')</expression>
</transformation>
</transformations>
</attribute>
<attribute>
<name>relationshipType</name>
<model>
<localizable>false</localizable>
<collection>false</collection>
<type>String</type>
<primaryKey>true</primaryKey>
</model>
<transformations>
<transformation>
<rawSource>RawDEBMAS</rawSource>
<expression>E1KNA1M-E1KNVVM-E1KNVPM-PARVW</expression>
</transformation>
</transformations>
</attribute>
<attribute>
<name>kunn2</name>
<model>
<localizable>false</localizable>
<collection>false</collection>
<type>String</type>
<primaryKey>false</primaryKey>
</model>
<transformations>
<transformation>
<rawSource>RawDEBMAS</rawSource>
<expression>E1KNA1M-E1KNVVM-E1KNVPM-KUNN2</expression>
</transformation>
</transformations>
</attribute>
<attribute>
<name>relationshipCounter</name>
<model>
<localizable>false</localizable>
<collection>false</collection>
<type>String</type>
<primaryKey>true</primaryKey>
</model>
<transformations>
<transformation>
<rawSource>RawDEBMAS</rawSource>
<expression>E1KNA1M-E1KNVVM-E1KNVPM-PARZA</expression>
</transformation>
</transformations>
</attribute>
<attribute>
<name>defaultPartner</name>
<model>
<localizable>false</localizable>
<collection>false</collection>
<type>String</type>
<primaryKey>false</primaryKey>
</model>
<transformations>
<transformation>
<rawSource>RawDEBMAS</rawSource>
<expression>E1KNA1M-E1KNVVM-E1KNVPM-DEFPA</expression>
</transformation>
</transformations>
</attribute>
</attributes>
</item>


Target-XML:

<item>
<type>CompanySalesPartnerRole</type>
<exportCode>SAPPartnerRole</exportCode>
<canonicalItemSource>CanonicalCustomPartnerRole</canonicalItemSource>
<updatable>true</updatable>
<attributes>
<attribute>
<name>owner</name>
<transformationExpression>resolve('CanonicalParty').externalPartyId.concat('_').concat(salesKey)</transformationExpression>
<exportCode>owner(B2BUnit.uid)</exportCode>
<mandatoryInHeader>true</mandatoryInHeader>
</attribute>
<attribute>
<name>publicKey</name>
<transformationExpression>partyId.concat('_').concat(salesKey)+'|'+relationshipCounter+'|'+'KNA1'+'|'+relationshipType</transformationExpression>
<exportCode>publicKey[unique=true]</exportCode>
<mandatoryInHeader>true</mandatoryInHeader>
</attribute>
<attribute>
<name>relationshipType</name>
<exportCode>parvw</exportCode>
<transformationExpression>relationshipType</transformationExpression>
<mandatoryInHeader>true</mandatoryInHeader>
</attribute>
<attribute>
<name>kunn2</name>
<exportCode>kunn2</exportCode>
<transformationExpression>kunn2</transformationExpression>
<mandatoryInHeader>true</mandatoryInHeader>
</attribute>
<attribute>
<name>relationshipCounter</name>
<exportCode>parza</exportCode>
<transformationExpression>relationshipCounter</transformationExpression>
<mandatoryInHeader>true</mandatoryInHeader>
</attribute>
<attribute>
<name>defaultPartner</name>
<exportCode>defaultPartner</exportCode>
<transformationExpression>defaultPartner</transformationExpression>
<mandatoryInHeader>false</mandatoryInHeader>
</attribute>
</attributes>
</item>


Target-XML - RelationObject:

<item>
<type>CompanyPartnerRoleRelation</type>
<exportCode>B2BUnit2SAPPartnerRole</exportCode>
<canonicalItemSource>CanonicalPartyRelationshipSales</canonicalItemSource>
<updatable>false</updatable>
<attributes>
<attribute>
<name>partyId</name><!-- externalPartyId = "CustomerID" = 0010000123 -->
<transformationExpression>resolve('CanonicalParty').externalPartyId.concat('_').concat(salesKey)</transformationExpression>
<exportCode>source(B2BUnit.uid)</exportCode>
<mandatoryInHeader>true</mandatoryInHeader>
</attribute>
<attribute>
<name>partnerRoles</name><!-- CanonicalCustomPartnerRole.publicKey -->
<transformationExpression>resolve('CanonicalParty').partyId.concat('_').concat(salesKey)+'|'+relationshipCounter+'|'+'KNA1'+'|'+relationshipType</transformationExpression>
<exportCode>target(publicKey)[unique=true]</exportCode>
<mandatoryInHeader>true</mandatoryInHeader>
</attribute>
</attributes>
</item>

Accepted Solutions (0)

Answers (0)