on 10-21-2009 9:48 AM
Hi ,
I have a requirement like this :
I am getting values in the below format in a table.
here comaony code and cost center are same for 3 values . so i want to add the three values (110usd30usd40usd = 170usd) and it has to display as follows :
amount assigned to :
110usd of 220 usd assigned to
company code 2001
cost center D800031
30usd of 220 usd assigned to
company code 2001
cost center D800031
40usd of 220 usd assigned to
company code 2001
cost center D800031
50usd of 220 usd assigned to
company code 1001
cost center D800031
here comaony code and cost center are same for 3 values . so i want to add the three values (110usd30usd40usd = 170usd) and it has to display as follows :
170usd of 220 usd assigned to
company code 2001
cost center D800031
50usd of 110 usd assigned to
company code 1001
cost center D800031
how to proceed on this ?pls guide me on this.
Thanks in advance.
Regards,
Rama
Hi Pavani,
Here you need to use two loops, i.e. , nested loop on the size of the node which is binded to the table as follows:
Assign the companycode, costcenter and cost to respective arrays
If the size of the aray is size , then
boolean check=false;
declare an 2D array result with dimensions [size] and [3]
for(int i=0; i<size;i++){
for(int j=0; j<size;j++){
if((companycode<i>==companycode[j]) && (costcenter<i>==costcenter[j])){
cost<i>= cost<i>+cost[j];
arrayi[0]=companycode<i>;
arrayi[1]=costcenter<i>;
arrayi[2]=cost<i>;
boolean=true;
}
}
if (!check){
arrayi[0]=companycode<i>;
arrayi[1]=costcenter<i>;
arrayi[2]=cost<i>;
}
}
}
Now you can get the values for the table. This is the logic that you can use.
Regards.
Rajat
Edited by: Rajat Jain on Oct 21, 2009 2:57 PM
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 | |
6 | |
6 | |
6 | |
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.