cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping Problems

Former Member
0 Kudos

Hi All,

I have the fallowing situation in my map:

The source is an XML document containing order information. This document contains multiple orders. Each order has 1 header and multiple items information, as following (example):

<ORDER>

<HEADER>

<NUMBER></ NUMBER>

<TYPE></TYPE>

<ORDER_ITEMS>

<ITEM> <ITEM_NUMBER></ITEM_NUMBER

<QTITY></ QTITY>

</ITEM>

</ORDER _ITEMS>

<HEADER>

</ORDER>

The result of the mapping/transformation will contain a row for each item. Each row will contain the header information from the source, and the item information, as following (example):

<ORDER>

<NUMBER></ NUMBER>

<TYPE></TYPE>

<ITEM_NUMBER></ITEM_NUMBER

<QTITY></QTITY>

</ITEM>

</ORDER>

I did the mapping but only one thing is not working:

All my header information in the target is coming from the first order. So no matter how many orders I put in the source, the target result is generated right for all item information, but the header is always the same.

This is the mapping witch I am doing for the header information:

Item ->

copyPerValue* -> Split by value -> Number

Number ->

copyPerValue: Java function

for (int i=0; i<a.length; i++) {

result.addValue(b[0]);

}

Tks a lot,

Daniela Machado

Accepted Solutions (1)

Accepted Solutions (1)

claus_wallacher
Active Participant
0 Kudos

Hi Daniela,

you should use function useOneAsMany. See also the attached <a href="/people/claus.wallacher/blog/2006/04/17/replication-of-nodes-using-the-graphical-mapping-tool">weblog</a>

Regards,

Claus

Former Member
0 Kudos

Claus,

I removed the copyPerValue function and put the useOneasMany one.

But when I test it with more then one order, I got an error:

RuntimeException in Message-Mapping transformation: Exception:[com.sap.aii.mappingtool.tf3.IllegalInstanceException: Too many values in first queue in function useOneAsMany. It must have the same number of contexts as second queue.] in class com.sap.aii.mappingtool.flib3.NodeFunctions method useOneAsMany[, , ]

Answers (2)

Answers (2)

claus_wallacher
Active Participant
0 Kudos

Daniela,

there are two things to look at:

1) Check that you have the context for each input variable set to the correct value

2) useOneAsMany only works if you always have at least one line item for each header line. Otherwise it will fail. In that case you would need to use one of the other options mentioned in the weblog.

If you can you post the sample XML you use for your testing, I can have a look at it and give you a better answer on what the problem is.

Regards,

Claus

Former Member
0 Kudos

Claus,

Thank you very very much!!!

It was my second parameter in the useOneAsMany function.

But know I fixed the problem and it worked!!

Thank you for your help,

Regards,

Daniela

Former Member
0 Kudos

Hi,

Let me guess here that from b[] you are getting header information in your function. Now you have done result.addValue(b[0]). that is every time you are using first element of header array. I suppose you want to use different header for all orders. Now for that you have to adjust your array element for b[]. Here using b[0] every time will not work. Now I don't have clear picture about what is that actually you need but i guess this will help.

Thanks.