on 02-12-2011 6:40 AM
Hi
my source structure looks like below, LinStatus occurs multiple times , so in this case i want to take the all values and add it and map to ID.how to achieve this
<Status>
<LinStatus>1..unbounded
<ID>
<Target>
<ID>
Regards,
Ram
Hi,
First of all map the output of ID field in source structure to removeContext node function to bring all the ID values in a single context.
Then map the output of removeContext to the UDF whose code is as below:
//This UDF takes a single String array input named instr[] and has a single ResultList item named result as output.
for(int j=0;i<instr.length;i++)
{
result.addValue ( instr [ j ] ); //please write j within third brackets, i have wriiten it but its not showing in my post
}
Map the output of this UDF to the ID field in the target structure. THAT'S IT .
I HAVE TESTED THE INTERFACE..IT WORKS FINE.
THANKS
BISWAJIT
Edited by: 007biswa on Feb 12, 2011 12:19 PM
Edited by: 007biswa on Feb 12, 2011 12:20 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
This UDF should work even if the input is decimal. It doesnot create any probelms. Else you can take an integer array as input and the rest of the code that i have written need not be changed at all. I have assumed that the ID in the target side has multiple(1..unbounded) occurrence under a single context unlike the source where there is context change for every value.
TRUST ME BUDDY, MY SOLUTION WILL WORK. I HAVE TESTED IT
THANKS
BISWAJIT
Hi,
Initially I didnot understand your requirement as it was not clear. Now it is very easy as you have gave a test instance.
For your requirement, use the code below:
double sum=0;
for(int i=0;i<instr.length;i++)
{
sum=sum+Double.parseDouble(instr[ i ]);
}
result.addValue ( sum);
please check the modified code now.
I HAVE TESTED THE CODE. IT WORKED FOR M
AND BEFORE THE UDF, USE THE removeContext NODE FUNCTION. IT IS MANDATORY HERE.
THNAKS
BISWAJIT
Edited by: 007biswa on Feb 12, 2011 4:02 PM
Edited by: 007biswa on Feb 12, 2011 4:06 PM
Edited by: Matt on Feb 14, 2011 6:55 AM
I think this can be achieved without UDF as well... have you tried with standard "Sum" function, e.g.
ID --- RemoveContext --- Sum --- ID
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.