cancel
Showing results for 
Search instead for 
Did you mean: 

Extending Data Hub with Custom Attribute

Former Member
0 Kudos

Hi All,

I'm trying to extend Data Hub with custom attribute from SAP ERP and pass that onto the hybris. In order to do so, I've followed the Data Hub Extensibility guide and some threads in the experts forum.

However I'm not able to validate my custom attribute in the RawMATMAS nor in canonical. The custom jar files are kept in webinf libs of the data hub. Below are the xmls. Please suggest what is going wrong. link text The version of hybris is 6.1.0.0 & Data Hub is 6.1.0.0 RC3. I'm also attaching complete console logs.

Quick responses will really be appreciated. Thanks Gourav

Raw XML:

 <dependencies>
         <dependency>
             <extension>zbalerpproduct-canonical</extension>
             <extension>saperpproduct-raw</extension>
             <extension>saperpproduct-canonical</extension>
             <extension>saperpproduct-target</extension>    
         </dependency>
     </dependencies>
 
     <rawItems>
         <item>
             <type>RawMATMAS</type>
             <description>Raw representation of a ZMATMAS</description>
             <attributes>
                 <attribute>
                     <name>E1MARAM-ZE1MARA-NITROGEN</name>
                 </attribute>                
             </attributes>
         </item>
     </rawItems>
 
     <canonicalItems>
         <item>
             <type>CanonicalProduct</type>
             <attributes>
                 <attribute>
                     <name>Nitrogen</name>
                     <transformations>
                         <transformation>
                             <rawSource>RawMATMAS</rawSource>
                             <expression>E1MARAM-ZE1MARA-NITROGEN</expression>
                         </transformation>
                     </transformations>
                 </attribute>                
             </attributes>
         </item>
 
     </canonicalItems>

Canonical XML:

 enter code here
 <dependencies>
         <dependency>            
             <extension>saperpproduct-raw</extension>
             <extension>saperpproduct-canonical</extension>
             <extension>saperpproduct-target</extension>        
         </dependency>
     </dependencies>
 
     <canonicalItems>
         <item>
             <type>CanonicalProduct</type>
             <description>Canonical representation of ZMATMAS</description>
             <status>ACTIVE</status>
             <attributes>
                 <attribute>
                     <name>Nitrogen</name>
                     <model>
                         <localizable>false</localizable>
                         <collection>false</collection>
                         <type>String</type>
                         <primaryKey>false</primaryKey>
                     </model>
                 </attribute>
                 
             </attributes>
         </item>
 
     </canonicalItems>

Target XML:

 <dependencies>
         <dependency>
             <extension>zbalerpproduct-canonical</extension>
             <extension>saperpproduct-raw</extension>
             <extension>saperpproduct-canonical</extension>
             <extension>saperpproduct-target</extension>    
         </dependency>
     </dependencies>
 
     <targetSystems>
         <targetSystem>
             <name>HybrisCore</name>
             <type>HybrisCore</type>
             <exportURL>${datahub.extension.exportURL}</exportURL>
             <userName>${datahub.extension.userName}</userName>
             <password>${datahub.extension.password}</password>
             <exportCodes>
                 <exportCode>
                     $catalogVersion=catalogversion(catalog(id[default=Default]),version[default='Staged'])[unique=true,default=Default:Staged]
                 </exportCode>
                 <exportCode>
                     $baseProduct=baseProduct(code,catalogVersion(catalog(id[default='Default']),version[default='Staged']))
                 </exportCode>
             </exportCodes>
             <targetItems>
                 <item>
                     <type>Product</type>
                     <exportCode>Product</exportCode>
                     <description>Hybris Platform representation of ZMATMAS</description>
                     <updatable>true</updatable>
                     <canonicalItemSource>CanonicalProduct</canonicalItemSource>
                     <status>ACTIVE</status>
                     <attributes> 
                         <attribute>
                             <name>Nitrogen</name>
                             <localizable>false</localizable>
                             <collection>false</collection>
                             <transformationExpression>resolve('CanonialProduct').Nitrogen</transformationExpression>
                             <exportCode>Nitrogen</exportCode>
                             <mandatoryInHeader>false</mandatoryInHeader>
                         </attribute>                        
                     </attributes>
                 </item>
             </targetItems>
         </targetSystem>
     </targetSystems>


former_member224482
Active Contributor
0 Kudos

Even if it is not a directly related error :

 2016-08-24 16:09:12,887 [ERROR] [c.h.d.e.l.i.DefaultExtensionResourceParseService] Extension cannot be loaded, missing properties :
 targetsystem.saps4hana.url,targetsystem.saps4hana.username,targetsystem.saps4hana.password,targetsystem.saps4hana.receivername

Add the local.properties :

 targetsystem.saps4hana.url=
 targetsystem.saps4hana.username=
 targetsystem.saps4hana.password=
 targetsystem.saps4hana.receivername=
Former Member
0 Kudos

Hi Robin,

Will this help is the error cannot load extension saperpproduct-raw? Should these be back end ERP system details? Can you please also suggest on the below issues? Thanks.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Gaurav, Please check your custom extensions (raw,canonical and target ) has been loaded successfully without any error . Your xml changes looks fine to me.

Former Member
0 Kudos

Hi Gourav, but in attached log ther isn't logged "Importing extension resource yourExtension-canonical" also for yourExtension-raw and yourExtension-taget, i suppose that yourExtension is zbalerpproduct.

Are you sure that the custom jars are in the correct folder?

Former Member
0 Kudos

Hi Andrea,

THanks for your response. yes, I could see that there was another older version of data hub working on the same box, causing the confusion, that I was deploying to but the working server was different. Had managed to get the custom attribute on the Data Hub side.

Now can you please suggest me how can I get this attribute to reflect on hybris side. What are the steps involved?

Thanks.

Former Member
0 Kudos

Hi Gourav,

I think that you must have the field Nitrogen in your Product in targetSystem.

After you should see the field in section Catalog-Product in Hybris.

If you want to check the update the RawMATMAS in dataHub got to http://localhost:8080/datahub-webapp/v1/item-classes/raw/item-types/RawMATMAS/attributes

and you should find E1MARAM-ZE1MARA-NITROGEN.

Former Member
0 Kudos

Hi Andrea,

If for a POC I want to map the custom attribute to an existing attribute value in the hybris side say description for example, can you please suggest where do we need to do the config.? To my understanding it is the export code field in the target xml where we need to refer it to which I've tried but not getting the value.

Also get publication error below: Could not transform by expression unit !=null and !unit.isEmpty() ? resolve('CanonicalProductUnit').EAN?:'' : resolve('CanonicalProduct').GTIN?: resolve('CanonicalProduct').resolve('CanonicalProductUnit')?.EAN?:''

Former Member
0 Kudos

Found the issue with EAN.

Can you please suggest on the correct field for mapping in the existing attribute for a POC. Thanks.

Former Member
0 Kudos

Hi Gourav,

I try to answer (if i understand).

Your raw-extention.xml should be

 <rawItems>
             <item>
                 <type>RawMATMAS</type>
                 <description>Raw representation of a sample raw item</description>
                 <attributes>
                     <attribute>
                         <name>E1MARAM-ERNAM</name><!-- MSGFN  -->
                     </attribute>
                 </attributes>
             </item>
         </rawItems>
     
         <canonicalItems>
             <item>
                 <type>CanonicalProduct</type>
                 <attributes>
                     <attribute>
                         <name>description</name>
                         <transformations>
                             <transformation>
                                 <rawSource>RawMATMAS</rawSource>
                                 <expression>E1MARAM-ERNAM</expression>
                             </transformation>
                         </transformations>
                     </attribute>
                 </attributes>
             </item>
Former Member
0 Kudos

Your canoncial-extention.xml should be

     <canonicalItems>
         <item>
             <type>CanonicalProduct</type>
             <description>Canonical representation of sample item</description>
             <status>ACTIVE</status>
             <attributes>
                 <attribute>
                     <name>description</name>
                     <model>
                         <localizable>false</localizable>
                         <type>String</type>
                         <primaryKey>false</primaryKey>
                     </model>
                 </attribute>
             </attributes>
         </item>
 
     </canonicalItems>
Former Member
0 Kudos

And target-extension.xml should be

                 <item>
                     <exportCode>Product</exportCode>
                     <type>BaseProduct</type>
                     <description>Products</description>
                     <updatable>true</updatable>
                     <canonicalItemSource>CanonicalProduct</canonicalItemSource>
                     <status></status>
                     <attributes>
                         <attribute>
                             <name>decription</name>
                             <localizable>false</localizable>
                             <transformationExpression >description.toLowerCase()</transformationExpression>
                             <exportCode>description</exportCode>
                             <mandatoryInHeader>false</mandatoryInHeader>
                         </attribute>
                     </attributes>
                 </item>

where exportCode is target system field to which it is mapped

I hope this helps you

Former Member
0 Kudos

Hi Andrea,

Thanks very much for your response. I've made changes to my existing xmls as you suggested below and has mapped to existing column comments. On publication I'm getting an error on the hybris console as well in the data hub backoffice UI. I'm attaching both. alt textPlease suggest.

Former Member
0 Kudos

Hi,

I also notice the attached error in loading the standard saperpproduct-raw extension even without my custom jars. Please suggest.link text

Former Member
0 Kudos

Hi Gourav,

sorry but for these errors I think it is a better an expert opinion. I'm new and I don't know them.

Sorry!

Former Member
0 Kudos

HI Andrea,

Above errors are sorted out but I still have some queries. In hybris, I've my custom itemtypes say product P1 wherein I've the above attribute nitrogen. I'm trying to map in the target xml to my custom itemtype say P1 so that in the back office I can see the product mapped to my custom product type but its not working. In the target xml, I've put in the export code as the target item type and the expressions resolving as ('CanonicalProduct').nitrogen. Can you please suggest what's missing? Thanks.

Former Member
0 Kudos

Hi Gaurav, I am also facing the GTIN/EAN issue as below..can you please advise me how did you fix it?

com.hybris.datahub.service.spel.TransformationExpressionException: Could not transform by expression GTIN?:resolve('CanonicalProductUnit')?.EAN?:''