cancel
Showing results for 
Search instead for 
Did you mean: 

Split many elements in others many elements

former_member200572
Participant
0 Kudos

Hi folks.

I have to follow source XML to map to receiver XML:


source
....
<SERVICE>
  <SRVNR>1001</SRVNR>
  <MATERIAL>
    <MATNR>QWERT</MATNR>
  </MATERIAL>
  <MATERIAL>
    <MATNR>ASDFG</MATNR>
  </MATERIAL>
</SERVICE>
<SERVICE>
  <SRVNR>2002</SRVNR>
</SERVICE>
<SERVICE>
  <SRVNR>3003</SRVNR>
  <MATERIAL>
    <MATNR>ZXCVB</MATNR>
  </MATERIAL>
</SERVICE>
....

receiver must be as follow
....
<MATERIAL>
  <SRVNR>1001</SRVNR>
  <MATNR>QWERT</MATNR>
</MATERIAL>
<MATERIAL>
  <SRVNR>1001</SRVNR>
  <MATNR>ASDFG</MATNR>
</MATERIAL>
<MATERIAL>
  <SRVNR>3003</SRVNR>
  <MATNR>ZXCVB</MATNR>
</MATERIAL>
....

but the result is below
<MATERIAL>
  <SRVNR>1001</SRVNR>
  <MATNR>QWERT</MATNR>
</MATERIAL>
<MATERIAL>
  <SRVNR>2002</SRVNR>
  <MATNR>ASDFG</MATNR>
</MATERIAL>
<MATERIAL>
  <SRVNR>3003</SRVNR>
  <MATNR>ZXCVB</MATNR>
</MATERIAL>

I've tried the code below:


 for (int i=0; i<a.length;i++){
  result.addValue(b[0]);
}

where the parameter a is my root <MATERIAL> and the parameter b is element <SRVNR>, but the result is wrong.

I've tried node function useOneAsMany but doesn't work too.

My difficult is associate root <SERVER> with corresponding roots <MATERIAL> in the result using either a node function or an user define function.

Someone can help me, please?

Thanks in advanced.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I got a answer for you... replicated same scenario in my IR, could test that and it is working great..

do you want me to send screen shots? or I can explain it to you..

fields are mapped like this;

Step 1)

MATNR ---> removeContexts --->MATERIAL

where MATNR context is changed to SERVICE

Step 2)

SRVNR -


>

MATERIAL -


>

MATNR -


>

in the same order all 3 fields go to -


> useOneAsMany -
> SplitByValue(Each Value) -
> SRVNR

again MATNR context is changed to SERVICE

Step 3)

MATNR ---> SplitByValue(Each Value) -


>MATNR

again MATNR context is changed to SERVICE ..

this should work for you.. please do try.. I have invested time to do this )

former_member200572
Participant
0 Kudos

Hi Prema.

I delayed to answer to you because your tip is was almost what I needed, but with it I got the solution.

I've never done an useOneAsMany function with a context instead of elements as you suggest.

My scenario it was a little more complex then I wrote, but now it's solved.

Thank you so much for the tip!

Former Member
0 Kudos

You are very welcome.. Happy that it worked for you..

Answers (3)

Answers (3)

Former Member
0 Kudos

?

Edited by: Wolfgang Disch on Apr 28, 2009 5:30 PM

Edited by: Wolfgang Disch on Apr 28, 2009 5:45 PM

Former Member
0 Kudos

ss

Edited by: Wolfgang Disch on Apr 28, 2009 5:45 PM

Former Member
0 Kudos

under node functions you can use 'split by value' on 'vale change' for SRVNR...

former_member200572
Participant
0 Kudos

Hi Prema.

I've done your tip but doesn't work.

Thanks

Former Member
0 Kudos

Make sure your UDF is context type.

I do not see any reason why useOneAsMany does not work.

Liang

Edited by: Liang Ji on Apr 22, 2009 9:02 PM

Former Member
0 Kudos

can you change the context of MATNR to SERVICE..