Skip to Content
0
Former Member
Oct 03, 2016 at 01:17 PM

Datahub error: Could not transform by expression miguel

427 Views

Hello Experts, I created a custom datahub(v5.7) and when i send a MATMAS05 sample IDOC works.

The probleme here is that i'm trying to add a custom attribute named "miguel". To do this i add this attribute on product type at the -items.xml:

 <itemtype code="Product" generate="false" autocreate="false">
                 <attributes>
                     <attribute qualifier="miguel" type="java.lang.String">
                         <persistence type="property"/>
                     </attribute>
                 </attributes>
 </itemtype>

Then i add this attribute from my raw extension:

 <dependencies>
         <dependency>
             <extension>saperpproduct-canonical</extension>
         </dependency>
     </dependencies>
 
     <rawItems>
         <item>
             <type>RawMATMAS</type>
             <description>ERP IDOC MATMAS</description>
             <attributes>
                 <attribute>
                     <name>E1MARAM-MIGUEL</name>
                 </attribute>
         </attributes>
     </item>
 </rawItems>

And here is my canonical extension:

 <dependencies>
         <dependency>
             <extension>zproduct-raw</extension>
             <extension>saperpproduct-raw</extension>
         </dependency>
     </dependencies>
 
 
     <canonicalItems>
         <item>
             <type>CanonicalProductSales</type>
             <attributes>
                 <attribute>
                     <name>miguel</name>
                     <model>
                         <localizable>false</localizable>
                         <collection>false</collection>
                         <type>String</type>
                         <primaryKey>false</primaryKey>
                     </model>
                     <transformations>
                         <transformation>
                             <rawSource>RawMATMAS</rawSource>
                             <expression>E1MARAM-MIGUEL</expression>
                         </transformation>
                     </transformations>
                 </attribute>
             </attributes>
         </item>
 
     </canonicalItems>

And my target extension:

 <dependencies>
         <dependency>
             <extension>zproduct-canonical</extension>
             <extension>saperpproduct-target</extension>
             <extension>saperpproduct-canonical</extension>
         </dependency>
     </dependencies>
 
     <targetSystems>
         <targetSystem>
             <name>HybrisCore</name>
             <type>HybrisCore</type>
             <exportURL>${targetsystem.hybriscore.url}</exportURL>
             <userName>${targetsystem.hybriscore.username}</userName>
             <password>${targetsystem.hybriscore.password}</password>
             <exportCodes>
                 <exportCode>#% impex.setLocale( Locale.ENGLISH )</exportCode>
             </exportCodes>
             <targetItems>
                 <item>
                     <exportCode>Product</exportCode>
                     <type>BaseProduct</type>
                     <description>Products</description>
                     <updatable>true</updatable>
                     <canonicalItemSource>CanonicalProductSales</canonicalItemSource>
                     <status>ACTIVE</status>
                     <attributes>
                         <attribute>
                             <name>miguel</name>
                             <localizable>false</localizable>
                             <collection>false</collection>
                             <transformationExpression>miguel</transformationExpression>
                             <exportCode>miguel</exportCode>
                             <mandatoryInHeader>false</mandatoryInHeader>
                         </attribute>
                     </attributes>
                 </item>
             </targetItems>
         </targetSystem>
     </targetSystems>


This is the sample MATMAS05 IDOC:

 <?xml version="1.0" encoding="UTF-8"?>
 <MATMAS05>
    <IDOC BEGIN="1">
       <EDI_DC40 SEGMENT="1">
          <TABNAM>EDI_DC40</TABNAM>
                         ...
          <SERIAL>20140929163446</SERIAL>
       </EDI_DC40>
       <E1MAEGMENT="1">
          <MSGFN>005</MSGFN>
                         ...
          <SLED_BBD>B</SLED_BBD>
       </E1MARAM>
    </IDOC>
 </MATMAS05>

If i call http://localhost:8080/datahub-webapp/v1/idoc/receiver with this sample IDOC the product is added succesfully.

So now i add the custom attribute to the sample IDOC like this:

 <?xml version="1.0" encoding="UTF-8"?>
 <MATMAS05>
    <IDOC BEGIN="1">
       <EDI_DC40 SEGMENT="1">
          <TABNAM>EDI_DC40</TABNAM>
                         ...
          <SERIAL>20140929163446</SERIAL>
       </EDI_DC40>
       <E1MAEGMENT="1">
          <MSGFN>005</MSGFN>
                         ...
          <SLED_BBD>B</SLED_BBD>
          <MIGUEL>makinon</MIGUEL>
       </E1MARAM>
    </IDOC>
 </MATMAS05>

And i check if my new attribute is in http://localhost:8080/datahub-webapp/v1/item-classes/canonical/item-types/CanonicalProductSales/attributes/ and http://localhost:8080/datahub-webapp/v1/item-classes/raw/item-types/RawMATMAS/attributes/

Everything seems to be right. Now i call the receiver with my custom sample IDOC and here is my error:

 2016-10-03 12:13:56,390 [ERROR] [c.h.d.s.s.i.CompilableSpelExpressionProcessor] EL1008E:(pos 0): Property or field 'miguel' cannot be found on object of type 'com.hybris.datahub.model.CanonicalItem'
  - maybe not public?
 2016-10-03 12:13:56,408 [ERROR] [c.h.d.s.p.i.DefaultCanonicalToTargetItemConverterService] Failed to create a target item from CanonicalItem{id='1', integrationKey='WEFCLNT504|SSSsuerte', status=SUC
 CESS, dataPool='DataHubPoolEntity{id=0, name=GLOBAL}', fields='{division=07, unit=pieces, GTIN=123, blocked=01, productID=SSSsuerte, isConfigurable=null, baseProductID=null, name=null, blockedFrom=2
 0140516, creationSystem=WEFCLNT504, creationDate=20140515}'}
 com.hybris.datahub.service.spel.TransformationExpressionException: Could not transform by expression miguel
         at com.hybris.datahub.service.spel.impl.CompilableSpelExpressionProcessor.transform(CompilableSpelExpressionProcessor.java:94) ~[datahub-service-6.0.0.0-RC12.jar:6.0.0.0-RC12]
         at com.hybris.datahub.service.publication.impl.DefaultCanonicalToTargetItemConverterService.populateAttributeFromCanonicalItem(DefaultCanonicalToTargetItemConverterService.java:94) ~[datahub
 -service-6.0.0.0-RC12.jar:6.0.0.0-RC12]
         at com.hybris.datahub.service.publication.impl.DefaultCanonicalToTargetItemConverterService.lambda$populateTargetItem$16(DefaultCanonicalToTargetItemConverterService.java:82) ~[datahub-servi
 ce-6.0.0.0-RC12.jar:6.0.0.0-RC12]
         at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) ~[na:1.8.0_77]
         at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175) ~[na:1.8.0_77]
         at java.util.HashMap$KeySpliterator.forEachRemaining(HashMap.java:1540) ~[na:1.8.0_77]
         at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) ~[na:1.8.0_77]
         at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) ~[na:1.8.0_77]
         at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) ~[na:1.8.0_77]
         at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) ~[na:1.8.0_77]
         at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:1.8.0_77]
         at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418) ~[na:1.8.0_77]
         at com.hybris.datahub.service.publication.impl.DefaultCanonicalToTargetItemConverterService.populateTargetItem(DefaultCanonicalToTargetItemConverterService.java:82) ~[datahub-service-6.0.0.0
 -RC12.jar:6.0.0.0-RC12]
         at com.hybris.datahub.service.publication.impl.DefaultCanonicalToTargetItemConverterService.convert(DefaultCanonicalToTargetItemConverterService.java:57) ~[datahub-service-6.0.0.0-RC12.jar:6
 .0.0.0-RC12]
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_77]
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_77]
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_77]
         at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_77]
         at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) [spring-aop-4.1.5.RELEASE.jar:4.1.5.RELEASE]
         at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) [spring-aop-4.1.5.RELEASE.jar:4.1.5.RELEASE]
         at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) [spring-aop-4.1.5.RELEASE.jar:4.1.5.RELEASE]
         at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) [spring-tx-4.1.5.RELEASE.jar:4.1.5.RELEASE]
         at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) [spring-tx-4.1.5.RELEASE.jar:4.1.5.RELEASE]
         at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) [spring-tx-4.1.5.RELEASE.jar:4.1.5.RELEASE]
         at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [spring-aop-4.1.5.RELEASE.jar:4.1.5.RELEASE]
         at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) [spring-aop-4.1.5.RELEASE.jar:4.1.5.RELEASE]
         at com.sun.proxy.$Proxy137.convert(Unknown Source) [na:na]
         at com.hybris.datahub.akka.actor.TargetItemCreator.createTargetItem(TargetItemCreator.java:58) [datahub-service-akka-6.0.0.0-RC12.jar:6.0.0.0-RC12]
         at akka.japi.pf.UnitCaseStatement.apply(CaseStatements.scala:26) ~[akka-actor_2.11-2.4.0.jar:na]
         at akka.japi.pf.UnitCaseStatement.apply(CaseStatements.scala:21) ~[akka-actor_2.11-2.4.0.jar:na]
         at scala.PartialFunction$class.applyOrElse(PartialFunction.scala:123) ~[scala-library-2.11.5.jar:na]
         at akka.japi.pf.UnitCaseStatement.applyOrElse(CaseStatements.scala:21) ~[akka-actor_2.11-2.4.0.jar:na]
         at scala.PartialFunction$OrElse.applyOrElse(PartialFunction.scala:170) ~[scala-library-2.11.5.jar:na]
         at akka.actor.Actor$class.aroundReceive(Actor.scala:480) ~[akka-actor_2.11-2.4.0.jar:na]
         at akka.actor.AbstractActor.aroundReceive(AbstractActor.scala:47) ~[akka-actor_2.11-2.4.0.jar:na]
         at akka.actor.ActorCell.receiveMessage(ActorCell.scala:525) ~[akka-actor_2.11-2.4.0.jar:na]
         at akka.actor.ActorCell.invoke(ActorCell.scala:494) ~[akka-actor_2.11-2.4.0.jar:na]
         at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:257) ~[akka-actor_2.11-2.4.0.jar:na]
         at akka.dispatch.Mailbox.run(Mailbox.scala:224) ~[akka-actor_2.11-2.4.0.jar:na]
         at akka.dispatch.Mailbox.exec(Mailbox.scala:234) ~[akka-actor_2.11-2.4.0.jar:na]
         at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) ~[scala-library-2.11.5.jar:na]
         at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) ~[scala-library-2.11.5.jar:na]
         at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) ~[scala-library-2.11.5.jar:na]
         at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) ~[scala-library-2.11.5.jar:na]
 Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 0): Property or field 'miguel' cannot be found on object of type 'com.hybris.datahub.model.CanonicalItem' - maybe
  not public?
         at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:226) ~[spring-expression-4.1.5.RELEASE.jar:4.1.5.RELEASE]
         at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:93) ~[spring-expression-4.1.5.RELEASE.jar:4.1.5.RELEASE]
         at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:81) ~[spring-expression-4.1.5.RELEASE.jar:4.1.5.RELEASE]
         at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:120) ~[spring-expression-4.1.5.RELEASE.jar:4.1.5.RELEASE]
         at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:242) ~[spring-expression-4.1.5.RELEASE.jar:4.1.5.RELEASE]
         at com.hybris.datahub.service.spel.impl.CompilableSpelExpressionProcessor.transform(CompilableSpelExpressionProcessor.java:89) ~[datahub-service-6.0.0.0-RC12.jar:6.0.0.0-RC12]
         ... 43 common frames omitted
 2016-10-03 12:13:56,454 [DEBUG] [c.h.d.r.j.JdbcBatchPublicationRetryRepository] Creating 1 retries
 [INFO] [10/03/2016 12:13:56.459] [DataHubActorSystem-akka.actor.default-dispatcher-5] [akka://DataHubActorSystem/user/$b/target-type-items-creator2] Completed Target Item creation for type BaseProdu
 ct

If i change <transformationExpression>miguel</transformationExpression> to <transformationExpression>"miguel"</transformationExpression> works but obviously always is writing "miguel" instead off "makinon" in this field.

And here is the generated impex:

 #% impex.setLocale( Locale.ENGLISH )
 INSERT_UPDATE Product;;catalogVersion(Catalog(id),version)[unique=true];miguel;code[unique=true];supercategories(code,catalogVersion(catalog(id),version));sapBaseUnitConversion;sapEAN;sapBlockedDate[dateformat='yyyyMMdd'];sapBlocked;variantType(code);sapConfigurable;unit(code)
 ;1;Default:Staged;miguel;SSSsuerte;<ignore>;1;123;20140516;true;;false;pieces


Like you can see 'miguel' attribute is in the impex header and "miguel" transformationexpression it's being added. But if i use <transformationExpression>miguel</transformationExpression> i get the error.

I don't know if what i'm trying to do it is possible and i need your help.

Thanks in advance.