Hi PI Experts,
I am working on FCC, where I have a requirement to sum the amounts and insert sum value in new row at the end of each context.
In details, Say suppose i have two queues one is Amount queue and another is Employee ID queue.
Based up on Employee ID queue, we need to sum each employee expensed amount and add the sum value in the same amount queue at the end of his expense amounts. Please find the expected output file attached.
Here, i am done with the summation of each employee based up on Employee ID queue using Graphical mapping. Since i am unable to achieve the requirement in Graphical mapping..i am working on UDF
I have all sum values of each employee in one queue and
i have a count where the position of each sum value needs to insert in another queue.
Now i need is to insert the values in the amount queue exectly where it requireds.
i have tried UDF as below
say, i have three queues
field1= 165.15,431.69,176.50,64.20,179.30,10.25,113.16,285.98,55.00,9.68,250.59,156.50,25.00
num1 = 1016.84,123.41,340.98,9.68,432.09
num2 = 5,2,2,13
UDF
*****
int length,i,j,length1,length2,count;
double temp;
count = 0;
length = 0;
length = 0;
length1 = 0;
length2 = 0;
j = 0;
length = field1.size();
length1 = num1.length;
length2 = num2.length;
for (i=0;i<length2;i++)
{
count = num2[j] + count + 1;
if(num2[j]<=length)
{
temp = num1[j];
field1.add(count-1,temp);
length = length + 1;
j = j + 1;
}
}
result.addValue(field1);
}
I am able to run successfully in Eclipse, but getting an error in PI.
Please correct me and let me know how i can achieve this.
Thanks in advance.
Thank you,
Chakradhar