cancel
Showing results for 
Search instead for 
Did you mean: 

Parent-child visual mapping

Former Member
0 Kudos

We are trying to perform the following mapping logic via visual mapping in SAP PI. The source data has the following structure:

<Item>

  <ID>

  </ID>

  <ItemAssignment>

    <ItemID>

    </ItemID>

  </ItemAssignment>

</Item>

For example:

<Item>

  <ID>

    10

  </ID>

  <ItemAssignment>

    <ItemID>

      20

    </ItemID>

  </ItemAssignment>

</Item>

<Item>

  <ID>

    20

  </ID>

</Item>

We are trying to map this data to a field in target structure that concatenates the child item with parent item (let's say separated by * character). So for above example it would be 20*10.

So in a more complex example:

20

  40

10

30

  10

  50

40

50

Needs to produce:

40*20

10*30

50*30

We have tried a number of approaches concatenating<ItemAssignment> with <Item> via UseOneAsMany, but have not been successful so far. At this point we are using XSLT to accomplish this, but were wondering if there is a way to achieve it via visual mapping instead.

Any help would be greatly appreciated.

Accepted Solutions (1)

Accepted Solutions (1)

rajasekhar_reddy14
Active Contributor
0 Kudos

Not sure  i understood your requirement correclty or not, but see below screen shots.

Former Member
0 Kudos

Raja,

Thank you for your reply.  Unfortunately we've tried your suggested approach originally and it does not seem to work primarily because only some of the items have itemassignments.  So when doing concatenation in the way you are describing it is concatenated incorrectly.  Here is an example:

Item 40 (in1) has ItemAssignment 0000000010 (in0).  Item 20 (in1) also has ItemAssignment 0000000010 (in0).  Items 30, 10 and KeyRec have no ItemAssignment.  The output needs to be:

0000000010*40

0000000010*20

But instead straight concatenation mapping that you suggest produces:

markangelo_dihiansan
Active Contributor
0 Kudos

Hello Anton,

Can you try this mapping?

ItemID context is set to Item

Test Results:

Hope this helps,

Mark

Former Member
0 Kudos

Bingo.  That works.  We will award points shortly.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Eric,

What Mark has suggested should work well except only in cases where, if the ItemID is not coming for any Item and you would still need the ID to be printed. In that case you can use the below mapping: