cancel
Showing results for 
Search instead for 
Did you mean: 

how to add values in target structucture

0 Kudos

hi all,

i have structure

subject (node)

subject name

marks

this is my source structure iam giving multiple values using duplicate sub tree and i want to add all the given marks for getting the total i want to know which node function is used to achieve this using graphical mapping

thanks in advance

Accepted Solutions (0)

Answers (3)

Answers (3)

anupam_ghosh2
Active Contributor
0 Kudos

Hi,

You can try the following mapping


             marks ------------>removeContexts------------>UDF-------->target field

The UDF is as shown below ( use advanced UDF of type "context")



public void totalMarks(String a[],ResultList result,Container container)
	{
		String t="";
		try
		{
			int i,sum=0;
			for(i=0;i<a.length;++i)
			{
				sum=sum+ new Integer(a<i>).intValue();
			}
			t=new Integer(sum).toString();
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		result.addValue(t);
	}

Hope this helps.

______________________________________________________________________________________________________

One small request from my end. If you feel your questions are being answered properly and correctly, could you please kindly

close down the threads. If threads are closed then we know for sure that solution has worked. Also an user with similar problem can use the solutions posted in the thread in future.

___________________________________________________________________________________________________

regards

Anupam

Former Member
0 Kudos

Hi,

I guess this will not work with Graphical mapping..I m not Sure abt it

But by writing simple UDF you can achieve this,

Execution type -- All values of Queue

marks as firstparameter

int mark1 =0;

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

{

mark1 = mark1+marks<i>;

String s = Integer.toString(mark1);

}

resultset.addValue(s);

Try this Once

Edited by: Deepthi Muppasani on Sep 14, 2011 8:17 AM

Former Member
0 Kudos

You can use Sum function. You will need to handle the context of input data.

Regards

Raj