2007 Jan 15 1:27 PM
Hi All,
I need to get the percentage of the amount allocated from 1 company to other company.
i put the data in internal table
pco rco amt percentage
A X 20k
A X 15k
A X 5k
i need to do collect so that same record can summate up
[internal table 2]
pco rco amt pct
A X 40k 27.97%
A Y 75k
A Z 28k
B S 68k
B F 47k
example above, co A has allocated its charges to co X,Y and Z where the total charges are 40k, 75k and 28k respectively. for co X, the percentage is (40/143)*100%. the same formula applies to other company.
May i know what method should be efficient to get the percentage that charge to each rco? Should i create another internal table called [total amount] with pco and total amt. when loop the [internal table 2] above i can read table of the [total amount] to get the total amount for each pco.
need advice.
thanks alot.
2007 Jan 15 1:35 PM
now ur internal table has
A X 20
A X 40
A X 5
A Y 40
A Z 40
A Z 30
B P 40
B Z 70
loop at itab.
collect itab.
endloop.
So itab will have
A X 65
A Y 40
A Z 70
B P 40
B Z 40
Now, take one more internal table itab2 which has
A 65
A 40
A 70
B 40
B 40
loop at itab1.
collect itab1.
endloop.
itab1 will have
A 175
B 80
loop at itab.
v_tabix = sy-tabix.
read table itab1 with key <field1> = itab-<field1>.
if sy-subrc = 0.
itab-field4 = (itab-field3/itab1-field2)* 100.
modify itab index v_tabix.
endif.
endloop.
Message was edited by:
Ramesh Babu Chirumamilla
Hi All,
I need to get the percentage of the amount allocated from 1 company to other company.
i put the data in internal table
pco rco amt percentage
A X 20k
A X 15k
A X 5k
i need to do collect so that same record can summate up
[internal table 2]
pco rco amt pct
A X 40k 27.97%
A Y 75k
A Z 28k
B S 68k
B F 47k
example above, co A has allocated its charges to co X,Y and Z where the total charges are 40k, 75k and 28k respectively. for co X, the percentage is (40/143)*100%. the same formula applies to other company.
May i know what method should be efficient to get the percentage that charge to each rco? Should i create another internal table called [total amount] with pco and total amt. when loop the [internal table 2] above i can read table of the [total amount] to get the total amount for each pco.
need advice.
thanks alot.
2007 Jan 15 1:35 PM
now ur internal table has
A X 20
A X 40
A X 5
A Y 40
A Z 40
A Z 30
B P 40
B Z 70
loop at itab.
collect itab.
endloop.
So itab will have
A X 65
A Y 40
A Z 70
B P 40
B Z 40
Now, take one more internal table itab2 which has
A 65
A 40
A 70
B 40
B 40
loop at itab1.
collect itab1.
endloop.
itab1 will have
A 175
B 80
loop at itab.
v_tabix = sy-tabix.
read table itab1 with key <field1> = itab-<field1>.
if sy-subrc = 0.
itab-field4 = (itab-field3/itab1-field2)* 100.
modify itab index v_tabix.
endif.
endloop.
Message was edited by:
Ramesh Babu Chirumamilla
2007 Jan 15 1:37 PM
hi,
yes make a new table ptab:
pco sum
A 143
B 115
..
so you can calculate when you loop your itab.
readt table ptab with key pco = itab-pco.
itab-percent = itab-amt / ptab-sum * 100.
Andreas
Message was edited by:
Andreas Mann
2007 Jan 15 11:56 PM
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |