Hi All,
I have been struck in message mapping.Below i am explaining it,
I have two input array,
one array lets call X [24]
[25]
[26]
[24]
[25]
other array is Y [10]
[11]
[12]
[13]
[14] .length of both the array will be same .
Now I want the output as: if there is any same value in first array i.e array X then corresponding value of second array should be added.i.e in array X if 24 is coming as twice (1st and 4th) then 1st and 4th value of array Y will be added.So here there will be only three output as Z[23]
[25]
[12]
Please guide me if posiible .I tried to use the for loop but its not working as the value of X is repeating.
Regards,
Saurabh
Hi Sentil,
My problem is at all not realted with BPM .Its simple mapping problem where ineed to write some UDF to achive the functionality .The problem is that it can't be achived by simple array so we might have to use Linked List or Set .
Hi,
use collect pattern method
/people/sravya.talanki2/blog/2005/08/24/do-you-like-to-understand-147correlation148-in-xi
http://help.sap.com/saphelp_nw2004s/helpdata/en/a5/64373f7853494fe10000000a114084/frameset.htm
BPM CollectPattern..
http://help.sap.com/saphelp_nw2004s/helpdata/en/08/16163ff8519a06e10000000a114084/frameset.htm
thanks,
sendil
Hi Saurabh,
This is fairly simple and you can do it without UDF.
Here is the solution :
1. Sort first array ( make sure that all the values are in single context )
2. Sort second array by key and the key will be sorted first array. ( here alos all values of second array should be in a single context )
3. apply split by value function with parameter value change on first array.
4. apply format by example function on second array with first argument to that format by example will be your second array and second argument will be output of step 3
5. then use sum function and you will get the desired output.
Try this and check the queues at each step.
Reward points if it helps you
Regards,
Shri
Hi,
Try this UDF
public void test(String[] a,String[] b,ResultList result,Container container) { for(int i=0;i<a.length;i++) { for(int j=i+1;j<a.length;j++) { if(a<i>==a[j]) { int c = Integer.parseInt(b<i>)+Integer.parseInt(b[j]); String d = new Integer(c).toString(); result.addValue (d); } } } }
Thanks
SaNv...
Hi Santosh,
your UDF solution is the right approch in beginning I have also tried the same approch .But it has one major problem. The array X values are repeating so once you Used the value then you have to delete the value from the firs array otherwise it will be get duplicated.
For Ex in first foo loop at first it will search for 24 now at second time again it may find 24 in that case it will be problem .It might be the all the value of Array X is same then iwant only one output as some of all.but with the uDf you have written it will produce more than one output.Please ask if you have any confusion
Add a comment