Skip to Content
0
Apr 21, 2017 at 12:24 AM

How to map a collection to a target attribute from an iDoc field that is a String?

140 Views

I'm working with v 6.3.0.2-RC1 and I'm mapping additional fields from an iDoc to a target item.

We were asked to map to Product's supercategories attribute but not in the standard way, by default in saperpproduct-target the mapping is done with the productId attribute calling a method determineSupercategories:

 <attribute>
     <name>supercategories</name>
     <collection>true</collection>
     <transformationExpression>determineSupercategories(productID)</transformationExpression>
     <exportCode>supercategories(code,catalogVersion(catalog(id),version))</exportCode>
 </attribute>

Now let me explain how is the mapping that got requested: in MATMAS iDoc, the field E1MARAM-PRDHA will have a string like T0005T0006T000010, this string needs to be broken down into strings delimited by the T character, so we'll have T0005, T0006 and T000010. Each one of these strings needs to be compared with their corresponding supercategory and get the correct name for it, then it needs to be passed down to the supercategories attribute in the target item.

So if T0005 equals to CategoryOne, T0006 equals to CategoryTwo and T000010 equals to CategoryThree in Hybris, collection containing those three values should be mapped to supercategories attribute.

How can I achieve this kind of mapping? Is the way I'm being asked to do the mapping a correct way? Bear with me since I'm new to Data Hub and Hybris altogether so some concepts haven't landed on me yet but have no problem if you explain it to me.