cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to Override OOB canonicalItem CanonicalPricingSalesAreaMapping?

Former Member
0 Likes
1,116

Hi,

I just want to override the OOB canonicalitem (CanonicalPricingSalesAreaMapping) attribute (distributionchannel-true).

I am getting the below error.

2018-06-26 01:22:24,547 [WARN] [c.h.d.s.s.i.DefaultItemResolver] Reference to CanonicalPricingSalesAreaMapping is not complete. com.hybris.datahub.composition.key.IncompleteKeyException: Value for attribute distributionChannel of canonical item CanonicalPricingSalesAreaMapping is blank or null. at com.hybris.datahub.composition.key.AlphabeticalIntegrationKeyGenerationStrategy.generateKeyValue(AlphabeticalIntegrationKeyGenerationStrategy.java:37) at com.hybris.datahub.composition.key.DefaultIntegrationKeyGenerator.calculateIntegrationKey(DefaultIntegrationKeyGenerator.java:75) at com.hybris.datahub.composition.key.DefaultIntegrationKeyGenerator.calculateIntegrationKey(DefaultIntegrationKeyGenerator.java:56) at com.hybris.datahub.service.spel.impl.DefaultItemResolver.calculateIntegrationKey(DefaultItemResolver.java:96) at com.hybris.datahub.service.spel.impl.DefaultItemResolver.lookupReferencedItemByMatchingKey(DefaultItemResolver.java:88) at com.hybris.datahub.service.spel.impl.DefaultItemResolver.resolveReference(DefaultItemResolver.java:76) at com.hybris.datahub.service.spel.impl.DefaultItemResolver.resolve(DefaultItemResolver.java:57) at com.hybris.datahub.service.spel.impl.ResolveMethodExecutor.execute(ResolveMethodExecutor.java:48) at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:130) at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:86) at org.springframework.expression.spel.ast.CompoundExpression.getValueRef(CompoundExpression.java:51) at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:87) at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:121) at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:262) at com.hybris.datahub.service.spel.impl.CompilableSpelExpressionProcessor.transform(CompilableSpelExpressionProcessor.java:84) at com.hybris.datahub.service.publication.impl.DefaultCanonicalToTargetItemConverterService.populateAttributeFromCanonicalItem(DefaultCanonicalToTargetItemConverterService.java:101) at com.hybris.datahub.service.publication.impl.DefaultCanonicalToTargetItemConverterService.lambda$populateTargetItem$0(DefaultCanonicalToTargetItemConverterService.java:89) at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175) at java.util.HashMap$KeySpliterator.forEachRemaining(HashMap.java:1548) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418) at com.hybris.datahub.service.publication.impl.DefaultCanonicalToTargetItemConverterService.populateTargetItem(DefaultCanonicalToTargetItemConverterService.java:89) at com.hybris.datahub.service.publication.impl.DefaultCanonicalToTargetItemConverterService.convert(DefaultCanonicalToTargetItemConverterService.java:60) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498)

Accepted Solutions (1)

Accepted Solutions (1)

mansurarisoy
Contributor
0 Likes

Firstly, distributionChannel attribute of CanonicalPricingSalesAreaMapping is a primaryKey so it cannot be null and when you are searching with key attributes of this canonical item you cannot give null values as parameters. This is the reason of the error you get when you're not sending distribution channel with IDoc (Data Hub interprets this value as null when it cannot find corresponding segment).

Secondly, you cannot override the definition of the canonical item's attributes, when you try this, Data Hub gives error during startup. But you may override the transformation of this attribute by using the following code snippet in your custom extension which has a dependency on the required extension (`sappricing-raw` in this case):

 <item>
 <type>CanonicalPrice</type>
 <attributes>
     <attribute>
         <name>distributionChannel</name>
         <transformations>
             <transformation override="true">
                 <rawSource>RawCOND_A</rawSource>
                 <expression spel="true">#root.getField('E1KOMG-VTWEG') ne null ? #root.getField('E1KOMG-VTWEG') : 'NDC'</expression>
             </transformation>
         </transformations>
     </attribute>
 </attributes>
 </item>

This code snippet overrides the distributionChannel attribute, and in the SpEL expression it checks the field of the IDoc where you're sending distribution channel value ( E1KOMG-VTWEG ) and if it's not null then it uses the value, otherwise it uses value NDC (Short for No-Distribution-Channel). Now you need to define mapping in Hybris for the distribution channel we defined for null values (NDC) to an appropriate value. After that you will not get the aforementioned error since you replaced null values with a non-null value (NDC in this case).

Hope this helps,
Mansur

Former Member
0 Likes

Hi Mansur, Thanks for your quick response. I did the same thing which you have explained,in that case the error is resolved.but i am getting a new error,please have a look at the below error and kindly let me know if i have missed anything or need to do something else. com.hybris.datahub.service.spel.TransformationExpressionException: Could not transform by expression resolve('CanonicalPricingSalesAreaMapping', 'SAPCONFIGURATION_POOL').c at com.hybris.datahub.service.spel.impl.CompilableSpelExpressionProcessor.transform(CompilableSpelExpressionProcessor.java:89)

Answers (2)

Answers (2)

Former Member
0 Likes

Error :- com.hybris.datahub.service.spel.TransformationExpressionException: Could not transform by expression resolve('CanonicalPricingSalesAreaMapping', 'SAPCONFIGURATION_POOL').c at com.hybris.datahub.service.spel.impl.CompilableSpelExpressionProcessor.transform(CompilableSpelExpressionProcessor.java:89) at com.hybris.datahub.service.publication.impl.DefaultCanonicalToTargetItemConverterService.populateAttributeFromCanonicalItem(DefaultCanonicalToTargetItemConverte at com.hybris.datahub.service.publication.impl.DefaultCanonicalToTargetItemConverterService.lambda$populateTargetItem$0(DefaultCanonicalToTargetItemConverterServic at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175) at java.util.HashMap$KeySpliterator.forEachRemaining(HashMap.java:1548) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418) at com.hybris.datahub.service.publication.impl.DefaultCanonicalToTargetItemConverterService.populateTargetItem(DefaultCanonicalToTargetItemConverterService.java:89 at com.hybris.datahub.service.publication.impl.DefaultCanonicalToTargetItemConverterService.convert(DefaultCanonicalToTargetItemConverterService.java:60) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

mansurarisoy
Contributor
0 Likes

Do you have anything like resolve('CanonicalPricingSalesAreaMapping', 'SAPCONFIGURATION_POOL').c in your transformation definitions? Maybe you defined it earlier for a test, if that so, try starting Data Hub with datahub.autoInitMode=create-drop mode and see if the error occurs again.

Former Member
0 Likes

Hi Mansur,

I have tried that way also still getting the same error.

mansurarisoy
Contributor
0 Likes

What about my first question? Is there any transformation expression like resolve('CanonicalPricingSalesAreaMapping', 'SAPCONFIGURATION_POOL').c in your code?

Former Member
0 Likes

Hi Mansur,

There is no transforamtion like resolve('CanonicalPricingSalesAreaMapping', 'SAPCONFIGURATION_POOL').catalogVersion in my code.

Former Member
0 Likes

Hi Mansur,

Any other thoughts so that i can try ..

mansurarisoy
Contributor
0 Likes

If you are sure that there is no transformation like the one in the log, try re-building extensions with mvn clean install command and start Data Hub with datahub.autoInitMode=create-drop mode

Former Member
0 Likes

Hi,

Even I am facing the same issue, by any chance did you find any solution for it ( if so please let me know).

Former Member
0 Likes

I have resolved the issue. It's a change in SAP Global Configuration --> Pricing Replication on the HMC side , we would need to add the Sales Organization, Distribution Channel, Owning Division and respective Catalog Version for pricing condition. After adding all the Mapping Sales Area Catalogs, need to save it and then upload it to the Data Hub.

Thanks!

Former Member
0 Likes

,

Please share the configurations steps.

Regards, Gaurav

Former Member
0 Likes

which configuration step ?