08-15-2007 7:27 PM
Hello I have an internal table with 12 months in a particular row and have amount in it.
Month01 month02 month03 month0 4 month11 month12
10 20 10 30 20 40
I know the starting and the end month and I have to add all the values in the period range.
Suppose my starting month is 01 and end month 13, my total should be 40,
Similarly if my starting month is month 02 and the end month is 02 then the total should be 30.
Any suggestions.
Thanks
Ster
08-15-2007 7:32 PM
08-15-2007 7:39 PM
HI,
Do this.
data : lv_diff type i.
lv_diff = endmonth - startmonth.
lv_month = startmonth.
loop at itab.
clear lv_total.
do lv_diff times.
case lv_month.
when '01'.
lv_total = lv_total + itab-month1.
when '02'.
lv_total = lv_total + itab-month2.
....
when '12'
lv_total = lv_total + itab-month12.
endcase.
lv_month = lv_month + 1.
enddo.
<b>here you will have lv_total with the required months total</b>
endloop.
Thanks
mahesh