cancel
Showing results for 
Search instead for 
Did you mean: 

Help with Mapping Tool and Nodes

0 Kudos

i have this problem, but i dont know how to make it

Source

-



<rs>
  <row>
   <PEOSN>2020202</PEOSN>
   <PEDET>sku01,10;sku02,12;</PEDET>
  </row>
  <row>
   <PEOSN>2020203</PEOSN>
   <PEDET>sku11,12;sku15,13;sku09,14;</PEDET>
  </row>
</rs>

Target

-



<detail>
  <item>
   <number>2020202</number>
   <sku>sku01</sku>
   <value>10</value>
  </item>
  <item>
   <number>2020202</number>
   <sku>sku02</sku>
   <value>12</value>
  </item>
  <item>
   <number>2020203</number>
   <sku>sku11</sku>
   <value>12</value>
  </item>
  <item>
   <number>2020203</number>
   <sku>sku15</sku>
   <value>13</value>
  </item>
  <item>
   <number>2020203</number>
   <sku>sku09</sku>
   <value>14</value>
  </item>
</detail>

i have already used this reference

[;

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi !

Check this screenshots:

http://picasaweb.google.es/matiwork/Levy_gonzalez_xi

it's the solution for your scenario.

you have here the mapping and code for the UDFs.

Regards,

Matias.

0 Kudos

thanks Matias, I hope the next week i will post the answered in this forum on ascii solution.

your images i helped it so much...

really thanks Matias

Levy G.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi !

You should use several UDFs to reach your goal...for example

one advanced UDF called "getNumber" that receives as input parameter the PEOSN and PEDET fields, and outputs as many repetitions of the PEOSN value as ";" are in the PEDET parameter..it should output a queue and should link the output value array to the "number" and "item" nodes in the target message.

another advanced UDF called "getSKU" that receives as input the PEDET field and returns as output, an array with the "sku" part of the input PEDET field. This udf should fill the target field "sku".

another advanced UDF called "getValue" that does the same as "getSKU" but only with the "value" portion of each sku+value pair.

Use javascript code like

String[] values = a[0].split(";");

for(int i=0; i<values.length; i++){

result.addValue(values<i>);

}

to fill the output value array based on how many pairs are in the PEDET field (inside the udf it is referenced as a[0]).

Regards,

Matias.