Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

ABAB CODE

Former Member
0 Kudos

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

2 REPLIES 2

Former Member
0 Kudos

Thanks all for looking. Got it myself.

Ster

Former Member
0 Kudos

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