cancel
Showing results for 
Search instead for 
Did you mean: 

How to split a list in graphical mapping?

former_member198060
Participant
0 Kudos

Hello,

My requirement is to split a list of incoming items into three lists of outgoing items:

Input:


<?xml version="1.0" encoding="UTF-8"?>

<items>

  <item>

  <name>a</name>

  <color>blue</color>

  <size>xl</size>

  </item>

  <item>

  <name>c</name>

  <color>yellow</color>

  <size>xxl</size>

  </item>

  <item>

  <name>b</name>

  <color>blue</color>

  <size>l</size>

  </item>

  <item>

  <name>c</name>

  <color>blue</color>

  <size>m</size>

  </item>

  <item>

  <name>a</name>

  <color>red</color>

  <size>xl</size>

  </item>

  <item>

  <name>d</name>

  <color>red</color>

  <size>s</size>

  </item>

</items>

expected output:


<?xml version="1.0" encoding="UTF-8"?>

<items>

<blueItems>

  <item>

  <name>a</name>

  <color>blue</color>

  <size>xl</size>

  </item>

  <item>

  <name>b</name>

  <color>blue</color>

  <size>l</size>

  </item>

  <item>

  <name>c</name>

  <color>blue</color>

  <size>m</size>

  </item>

</blueItems>

<yellowItems>

  <item>

  <name>c</name>

  <color>yellow</color>

  <size>xxl</size>

  </item>

</yellowItems>

<redItems>

  <item>

  <name>a</name>

  <color>red</color>

  <size>xl</size>

  </item>

  <item>

  <name>d</name>

  <color>red</color>

  <size>s</size>

  </item>

</redItems>

</items>

So I have a list that needs to be split by a condition. Is this possible to achieve with graphical mapping or do we have to use UDF in this case?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Peter ,

For every top node i.e. Blueitems , YellowItems and red items you can put a condition for CREATEIF when the color is Blue , Yellow and Red respectively.

You may need to handle some context for achieving this but it is possible.

Thanks.

Answers (2)

Answers (2)

Former Member
0 Kudos

I guess this link -

http://wiki.scn.sap.com/wiki/display/XI/Split+Mapping+using+UDF

would help, though with UDF

former_member187587
Contributor
0 Kudos

Hi there Peter,

If the split occures based on the value provided in the color field I beleive this is possbile

but you'll need to use sort and splitByValue.

you might need to use more then 1 mapping program (you can run them one by one inside the operation mapping).

I beleive it will be possible to perform it without a UDF but mind you that you re-structure the paylod

and this might have buisness effects on your solution (if a context in a message is needed)