cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping issue

Former Member
0 Kudos

My Source structure:

<IDOC> [1...1]

<ZCNT> [1....9999999]

<CCTNR></CCTNR> [0..1]

<ZARTICLE> [0.....9999999]

<field1></field1> [0...1]

<field2><field2> [0...1]

</ZARTICLE>

</ZCNT>

</IDOC>

My target structure:

<items> [0...1]

<item> [0...unbounded]

<fieldX>

</item>

<item> [0....unbounded>

<fieldu>

<fieldz>

</item>

</items>

My Source data:

<IDOC>

<ZCNT>

<CCTNR>123</CCTNR>

<ZARTICLE>

<field1>x</field1>

<field2>y</field2>

</ZAR|TICLE>

</ZCNT>

<CCTNR>456</CCTNR>

<ZCNT>

<ZARTICLE>

<field1>u</field1>

<field2>z</field2>

</ZAR|TICLE>

</ZCNT>

</IDOC>

My Requirement:

The first instance of ITEM must occur for every instance of ZCNT

The second instance of ITEM must occur for every instance of ZARTICLE

So my output should look like

<items>

<item>

<fieldx>123</fieldx>

</item>

<item>

<fieldu>x</fieldu>

<fieldz>y<fieldz>

</item>

<item>

<fieldx>456</fieldx>

</item>

<item>

<fieldu>u</fieldu>

<fieldz>z</fieldz>

</item>

</items>

My mapping:

IDOC -->ITEMS

ZCNT -->SPLITBYVALUE -->ITEM [first instance of ITEM]

CCTNR --> fieldx

ZARTICLE --> ITEM [2nd instance of ITEM]

field1 -->fieldu

field2 -->fieldz

The output I get is:

<items>

<item>

<fieldX>123</fieldx>

</item>

<item>

<fieldu>x</fieldu>

<fieldz>y<fieldz>

</item>

</items>

For some reason , I do not get the second set of values for both ZCNT and ZARTCILE. If I do remove contexts from the 2nd instance of item

ZARTICLE>removecontexts>ITEM [2nd instance of ITEM]

then the output I get is

<items>

<item>

<fieldX>123</fieldx>

</item>

<item>

<fieldu>x</fieldu>

<fieldz>y<fieldz>

</item>

<item>

<fieldu>u</fieldu>

<fieldz>z</fieldz>

</item>

</items>

But I do not get the 2nd instance of ZCNT. What we should keep in mind is that one ZCNT can have many ZARTICLES...so the number of contexts of

ZCNT need not necessarily match the number of contexts of ZARTICLES.

Is it feasible to get a structure as mentioned in my requirement. Your help would be most welcome.

Accepted Solutions (1)

Accepted Solutions (1)

moorthy
Active Contributor
0 Kudos

Hi,

Did you try RemoveContext with SplitByValue ? If not try it once.

Following blog will give some good example-

/people/sravya.talanki2/blog/2005/12/08/message-mapping-simplified-150-part-ii

/people/claus.wallacher/blog/2006/04/17/replication-of-nodes-using-the-graphical-mapping-tool

Regards,

Moorthy

Former Member
0 Kudos

Hi,

I had already tried the methods suggested in those 2 weblogs. It did not work. When I do that, only the data relating to the first ZCNT appears on the target side. The second one does not appear.

Thanks,

Vikram

Former Member
0 Kudos

Hi,

Can you try

splitbyvalue-collapse contextZCNT

splitbyVaue----ZARCTICLE

Also, check on this:

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/8a57d190-0201-0010-9e87-d8f...

Regards

Vijaya

Answers (1)

Answers (1)

stefan_grube
Active Contributor
0 Kudos

It is not possible to have alternating nodes out of the box with the graphical mapping tool.

In yourcase I assume that the problem cannot be solved without using a UDF.

First create a target structure like this:

items
-> item
  -> fieldx
     fieldu
     fieldz

The UDF for fieldX has to create a Queue with these entries:

123 - CC - CC - 456 - CC

The UDF for fieldu has to create this:

CC - x - CC - CC - u

In other words: The fieldX is assigned to the first and third occurance of item, fieldu is assinged to the second and fourth occurance of item.

Regards

Stefan

Former Member
0 Kudos

Hi,

I also reached the conclusion that this structure may not be possible with just graphical mapping tool. So we decided to go with a different target structure which makes mapping a little easier.

Thanks for you help and inputs.

Regards,

Vikram