on 08-01-2008 9:55 AM
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 .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Saurabh,
This work perfect...
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++)
{
int p = Integer.parseInt(a<i>);
int q = Integer.parseInt(a[j]);
if(p==q)
{
int c = Integer.parseInt(b<i>)+Integer.parseInt(b[j]);
String d = new Integer(c).toString();
result.addValue (d);
}
}
}
}
Thanks
SaNv...
Hi Santosh,
Ur UDF approch is right but it does not solve my problem as .In array one if all the values are same I want only one output but with your approch I will get more than one output .actyally after one iteration of for loop I think we have to delete all the occurence of that value from the first array .Please giude me if u have any idea how to do this I hope using Linked list approc.
regards
Saurabh
Hi,
Tru this..
public void test(String[] a,String[] b,ResultList result,Container container){
int flaga,flagb;
for(int i=0;i<a.length;i++)
{
flaga =0;
for(int j=i+1;j<a.length;j++)
{
int p = Integer.parseInt(a<i>);
int q = Integer.parseInt(a[j]);
if(p==q)
{
flaga =1;
int c = Integer.parseInt(b<i>)+Integer.parseInt(b[j]);
String d = new Integer(c).toString();
result.addValue (d);
}
}
if (flaga ==0)
{
flagb=0;
for(int q =i-1; q>=0;q--)
{
if(Integer.parseInt(a<i>) == Integer.parseInt(a[q]))
flagb = 1;
}
if (flagb == 0) result.addValue((b<i>));
}
}
}
I have tested with the same input... it is working for me
http://www.flickr.com/photos/28929439@N06/2721471681/
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.