cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping

Former Member
0 Kudos

I have the following issue.

SOURCE:

CUST

Cust NR = 1

Name = A

CUST

Cust NR =3

Name = C

CUST

Cust NR = 2

Name = B

ITEM

Cust NR = 1

ItemName = ff

Amount = 20

ITEM

Cust NR = 1

ItemName = gg

Amount = 30

ITEM

Cust NR = 2

ItemName = yy

Amount = 25

ITEM

Cust NR = 3

ItemName = uu

Amount = 50

ITEM

Cust NR = 2

ItemName = ee

Amount = 80

Based on the above I want my target structure to then show

CUST

Cust NR = 1

Name = A

ITEM

Cust NR = 1

ItemName = ff

Amount = 20

ITEM

Cust NR = 1

ItemName = gg

Amount = 30

CUST

Cust NR = 2

Name = B

ITEM

Cust NR = 2

ItemName = yy

Amount = 25

ITEM

Cust NR = 2

ItemName = ee

Amount = 80

CUST

Cust NR = 1

Name = A

ITEM

Cust NR = 3

ItemName = uu

Amount = 50

So as you can see basically I want to group all of my items with their relevant customer....

I am able to do it when all items and customers appear in numerical order but everything goes wrong when I get customer 3 first or item 2 followed by 5 or so on...

I guess I want to group the relevant item nodes and al of there subelements with the relevane customer node and its subelements...

Message was edited by:

SAP XI

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Try this :

CUST-->CUST

Cust_NR--->Cust_NR

Name--->Name

3 inputs to UDF...same UDF we are using everywhere

Cust_NR->RemoveContext->UDF->SplitByValue[Each Value]>ITEM

Cust_NR->RemoveContext->UDF

Cust_NR->RemoveContext->UDF

CUST_NR(from CUST node)--->Cust_NR

Cust_NR->RemoveContext->UDF->SplitByValue[Each Value]>ItemName

Cust_NR->RemoveContext->UDF

ItemName>RemoveContext->UDF

Cust_NR->RemoveContext->UDF->SplitByValue[Each Value]>Amount

Cust_NR->RemoveContext->UDF

Amount-->RemoveContext->UDF

UDF with 3 input: a,b,c and result list

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

{

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

{

if(a<b>[</b>i<b>]</b>.equals(b[j]))

{

result.addValue(c[j]);

}

}

}

Hope this works.

Thanks,

Maheshwari.

Former Member
0 Kudos

Maheshwari,

Thank you so much... That solved my problem exactly... thats amazing!!!!!

Answers (2)

Answers (2)

Former Member
0 Kudos

Try this link:

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/01a57f0b-0501-0010-3ca9-d2e...

Covers grouping and aggregation of data in XML nodes.

Former Member
0 Kudos

Barry, It doesn't really help with my scenario..as I dont want to group all items into one single node... I simply want to Group all relevant items together with its customer

Former Member
0 Kudos

HI,

Use FormatByexample function in message mapping to group the items

or write a UDF to group by using Vectors or Hashmap.

Regards

Chilla

Former Member
0 Kudos

Chilla the format by example wont work because I could have one customer but 8 items hence the queue lengths would be different...

Am i correct?

Former Member
0 Kudos

HI

Yes correct, then in that case , the only one option is write the UDF in that use Vectors or Hashmap to hold the list and group accordingly.Actually we have one example in mapping patterns

see the below link to know more about ,mapping patterns

http://help.sap.com/bp_bpmv130/Documentation/Operation/MappingXI30.pdf

Regards

Chilla

Former Member
0 Kudos

OK so how would I code that... How many input values?

2 I guess?

and each element would have to go through this udf or just the parent node?

Former Member
0 Kudos

hi,

take the header field which is to based on group , and the rest of all fields take input and group accordingly. why to take item details for input because , we should group accordingly the Cust NR..

Regards

Chilla

Former Member
0 Kudos

sorry could you clarify that... i dont understand

Former Member
0 Kudos

HI,

In above link goto page no 150 around for mapping patterns

and do accordingly , there you can find the code

the input parameters are first CUST NR,

rest of the Item parameters whatever you want to group under Cust NR..

and before each input change the context to top root node, or removecontext and map to UDF.. after that use to map to target node. check the queue each stage by right click on each item..

and if you dont have the Context change in receiver side , then use Splitbyvalue fnction also..

Regards

Chilla

<i>reward points if it is helpful..</i>