2008 Feb 01 7:02 AM
Hi ,
I have an internal table in the following format.
date amount
01.01.2008 $50
10.01.2008 $50
02.12.2007 $100
14.12.2007 $100
17.12.2007 $100
Now the month and year for the first 2 values are same and for the next 3 are the same..
I want to sum the amount corresponding to the same month and year..
Jan 08 = 100
Dec07 = 300.
How to do this summation in the internal table and move to another internal table.
Kindly help.
Thanks.
if possible try convert the date field into yyyymmdd format. and sort the itab based on date field
try with this i am not sure.
loop itab.
at new date+0(6).
clear sum.
endat.
sum = sum+amt.
at end date+0(6).
display sum.
endat.
2008 Feb 01 7:07 AM
if possible try convert the date field into yyyymmdd format. and sort the itab based on date field
try with this i am not sure.
loop itab.
at new date+0(6).
clear sum.
endat.
sum = sum+amt.
at end date+0(6).
display sum.
endat.
2008 Feb 01 7:08 AM
Hi,
Do like this
data: lv_lines type i,
cnt type i.
Describe table itab lines lv_lines.
Loop at itab into wa.
cnt = cnt + 1.
if wa-date+3(2) = wa1-date+3(2).
wa1-amount = wa-amount + wa1-amount.
delete itab from wa.
append wa1 to itab.
endif.
if cnt = lv_lines.
exit.
endif.
wa1 = wa.
endloop.
Regards,
Satish
Edited by: Satish Panakala on Feb 1, 2008 7:10 AM
2008 Feb 01 7:13 AM
say the stucture of internal table is
data: begin of itab,
date
amount
end if itab.
*Totals table-
itot.(say)
then process as
loop at itab.
move corressponding itab to itot.
append itot.
On change of itab-date(6).
clear itot.
loop at itab.
itot-amount = itot-amount + itab-amount.
endloop.
append itot.
endon.
clear itot.
endloop.
Hope the above logic helps
Regards
Vijai
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |