cancel
Showing results for 
Search instead for 
Did you mean: 

how to sum all amount values in a context using UDF

Former Member
0 Kudos

Hi,

I have a single Amount field in each record. and there are multiple records. i want to add them using UDF and not using message mapping standard function 'SUM'. How do i write the UDF?

Thanks

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Pls use the above UDF like this. It's working fine.

amount->remove context(node function)->add_amount->split by value(node function)->target

Former Member
0 Kudos

Hi,

The above code in UDF will work fine...but along with it add below statement after

result.addValue(c);

result.addContextChange();

This will allow you to add this Amount field per record...

Thanks

swarup

Former Member
0 Kudos

Hi,

use the cache parameter as context.

amount-->add-->target


public void add_amount(String[] a,ResultList result,Container container)
{
String c;
int k;
int j = 0;
for(int i = 0; i <= a.length; i++)
{
    k = Integer.parseInt(a<i>);
    j = j+k;
}
c = String.valueOf(j);
result.addValue(c);

Edited by: malini balasubramaniam on Aug 18, 2008 11:11 AM