Skip to Content
author's profile photo Former Member
Former Member

Problem in Graphical message mapping.Need UDF to add array based on some co

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Aug 01, 2008 at 09:26 AM

    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 .

    Add a comment
    10|10000 characters needed characters exceeded

    • 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...

  • author's profile photo Former Member
    Former Member
    Posted on Aug 01, 2008 at 09:05 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 01, 2008 at 09:24 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 01, 2008 at 09:24 AM

    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...

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 01, 2008 at 09:41 AM

    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
    10|10000 characters needed characters exceeded

    • Former Member

      take 2 inputs as 2 arrays, adjust the context so that all values will come

      for(i=0;i<a.length;i++)
      {
      	temp=a<i>;
      	for(j=i+1;j<a.length-j;j++)  // j< a.length-j
      	{
      		if(temp==a[j]){
      			sum = b<i>+b<i>;
      			result.addValue(sum);
      			flag =1;
      		}
      	} //end for j
      	if(flag != 1){
      		result.addValue(b<i>);
      	}
      
      }// end for i

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.