cancel
Showing results for 
Search instead for 
Did you mean: 

Another message mapping complex issue

0 Kudos

Hi All.

I have to map one field on the condition of another field

the source can be like this

<Header>

<seg24>

<matpos>10</matpos>

<seg12>

<matdesc>red</matdesc>

<length>100</length>

</seg12>

<seg12>

<matdesc>green</matdesc>

<length>200</length>

</seg12>

<seg12>

<matdesc>black</matdesc>

<length>300</length>

</seg12>

</seg24>

<seg24>

<matpos>20</matpos>

<seg12>

<matdesc>red</matdesc>

<length>100</length>

</seg12>

<seg12>

<matdesc>green</matdesc>

<length>200</length>

</seg12>

<seg12>

<matdesc>black</matdesc>

<length>300</length>

</seg12>

</seg24>

<seg24>

<matpos>30</matpos>

<seg12>

<matdesc>red</matdesc>

<length>500</length>

</seg12>

<seg12>

<matdesc>green</matdesc>

<length>800</length>

</seg12>

<seg12>

<matdesc>black</matdesc>

<length>900</length>

</seg12>

</seg24>

<LineItem>

<Itempos>30</Itempos>

</LineItem>

<LineItem>

<Itempos>10</Itempos>

</LineItem>

<LineItem>

<Itempos>20</Itempos>

</LineItem>

</Header>

seg12 is a sub segment of seg 24

the target can be like this

<Target>

<field1></field1>

<field2></field2>

<targetlength></targetlength>

</Target>

I have only to map the <lenght> to <targetlength>.if the <matdesc> is red.

for this I have to compare the Itempos and matpos.

if <matdesc> is red -


if Itempos eq matpos -


<length> -


> <targetlength>.

the problem is in <material> node the <matpos> is in the right sequence (10,20,30) but in <Itempos> it in the opposite order(30,10,20).

I can not get the the comparison to return true because it is compares 1 --- 1 and comparing (10 to 30) and (20 to 10) .......... will fail and hence the field red is never mapped.

is there any way I can compare the 2 positions that at some point it will get the comparison to work.

Thanks in advance

Accepted Solutions (1)

Accepted Solutions (1)

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

the problem is in <material> node the <matpos> is in the right sequence (10,20,30) but in <Itempos> it in the opposite order(30,10,20).

I can not get the the comparison to return true because it is compares 1 --- 1 and comparing (10 to 30) and (20 to 10)

You can use this mapping to reorder the values in itempos


Itempos -> removeContext -> sort:ascending -> splitByValue:eachValue -> your comparison logic here

Hope this helps,

Mark

0 Kudos

Thanks

Sort solved the problem

BR

Answers (0)