Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

graphical mapping of tables on the same level

Hi,

I have a problem of mapping of XML similar to this:

<ns0:Items> (0..1)

<ns0:SimpleSale> (0..unbounded)

<ns0:ItemCode>0000931927</ns0:ItemCode>

<ns0:PlanningGroup>0718</ns0:PlanningGroup>

<ns0:SubPlanningGroup>7180</ns0:SubPlanningGroup>

<ns0:Quantity>1</ns0:Quantity>

<ns0:TotalSellingPrice>1299.99</ns0:TotalSellingPrice>

<ns0:PriceOverridden>false</ns0:PriceOverridden>

<ns0:Scanned>false</ns0:Scanned>

<ns0:CommissionEarner>1010101</ns0:CommissionEarner>

<ns0:AssistantID>1</ns0:AssistantID>

<ns0:Discount> (0..unbounded)

<ns0:Amount>-104.01</ns0:Amount>

<ns0:ReasonCode>AA</ns0:ReasonCode>

</ns0:Discount>

<ns0:Discount> (0..unbounded)

<ns0:Amount>-104.02</ns0:Amount>

<ns0:ReasonCode>BB</ns0:ReasonCode>

</ns0:Discount>

<ns0:DCOutfitOrderInfo> (0..1)

<ns0:Component> (0..unbounded)

<ns0:DistributionCentre>7422</ns0:DistributionCentre>

<ns0:ItemCode>0000747861</ns0:ItemCode>

<ns0:StockSource>B</ns0:StockSource>

</ns0:Component>

<ns0:Component> (0..unbounded)

<ns0:DistributionCentre>7422</ns0:DistributionCentre>

<ns0:ItemCode>0000925193</ns0:ItemCode>

<ns0:StockSource>L</ns0:StockSource>

<ns0:SaltNumber>2208340261</ns0:SaltNumber>

</ns0:Component>

</ns0:DCOutfitOrderInfo>

</ns0:SimpleSale>

</ns0:Items>

and I need to map it like this:

<ns0:Items> (0..unbounded)

<ns0:DistributionCentre>7422</ns0:DistributionCentre>

<ns0:ItemCode>0000747861</ns0:ItemCode>

<ns0:StockSource>B</ns0:StockSource>

<ns0:Discount> (0..unbounded)

<ns0:Amount>-104.01</ns0:Amount>

<ns0:ReasonCode>AA</ns0:ReasonCode>

</ns0:Discount>

<ns0:Discount> (0..unbounded)

<ns0:Amount>-104.02</ns0:Amount>

<ns0:ReasonCode>BB</ns0:ReasonCode>

</ns0:Discount>

</ns0:Items>

<ns0:Items> (0..unbounded)

<ns0:DistributionCentre>7422</ns0:DistributionCentre>

<ns0:ItemCode>0000925193</ns0:ItemCode>

<ns0:StockSource>L</ns0:StockSource>

<ns0:Discount> (0..unbounded)

<ns0:Amount>-104.01</ns0:Amount>

<ns0:ReasonCode>AA</ns0:ReasonCode>

</ns0:Discount>

<ns0:Discount> (0..unbounded)

<ns0:Amount>-104.02</ns0:Amount>

<ns0:ReasonCode>BB</ns0:ReasonCode>

</ns0:Discount>

</ns0:Items>

I changed context of <ns0:Component> to Items and mapped it to target <ns0:Items>. It's working fine. But I need to create 2 discount records for every component (target Item) record - I need to copy all discount records for every component.

I tried to use function UseOneAsMany in mapping of fileds <ns0:Discount> ---> <ns0:Discount> with parameters inp1: <ns0:Discount>; inp2: <ns0:ItemCode> (context changed to <ns0:SimpleSale>); inp3: <ns0:ItemCode>...

But there is compilation error which says, that there are too many values in first queue... The problem is, that I need to use the whole "discount" node and use it for every component (Item code). Is it possible to make it in graphical mapping?

I'll be happy for any help.

Former Member
Former Member replied

Hi,

you can achieve this by writing UDF.

// Cache type of UDF is "CONTEXT"

//two Input parameters:

//*** mapping to target DISCOUNT : input parameters are (1) Discount (2) Component (both in defauult context)

//*** mapping to subfields of DISCOUNT say Amount : input parameters are (1) Amount ( Context "SimpleSale" ) (2) Component (in default context)

//public void createNode(String[] a,String[] b,ResultList result,Container container){

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

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

result.addValue(a[j]);

}

if(i!=b.length-1){

result.addValue(ResultList.CC);

}

}

Regards

Ritu

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question