Skip to Content
0
Former Member
Jan 17, 2008 at 01:44 PM

Period totals

22 Views

Hi Gurus,

I have the following requirement where I'm stuck.

I have an internal table with the following fields and sample data.

it_temp:

bukrs hkont kostl kosar gjhar monat actual plan

1100 71100 120325 F 2007 01 100.00 100.00

1100 71100 120326 F 2007 02 0.00 100.00

1100 71100 120327 F 2007 03 100.00 100.00

1100 71100 120328 F 2007 04 100.00 100.00

1100 71100 120329 F 2007 05 10.00 100.00

1100 71100 130325 V 2007 01 100.00 100.00

1100 71100 130326 V 2007 02 100.00 100.00

1100 71100 130327 V 2007 03 100.00 100.00

I have a select option S_MONAT to enter the monat range from 01 to 12 which is basically the months.

S_MONAT is an obligatory field. Report is run only for ONE year.

Two possible ways of entry:

1. If user enters only say S_MONAT-LOW = 03, I set S_MONAT-LOW = 01 and S_MONAT-HIGH = 03.

2. If user enters a range say S_MONAT- LOW = 02 and S_MONAT-HIGH = 05, it stays the same.

Now what I need is to get the period actual amounts and year-to-date amounts in another table it_alv.

it_alv:

bukrs kosar mactual mplan year-to-date-actual year-to-date-plan

Case1: User enters only S_MONAT-LOW = 03

In this case mactual, mplan would correspond to the record with monat = '03'

year-to-date would be sum of mactual01 mactual02mactual03 and mplan01mplan02mplan03

Case2: User enters S_MONAT-LOW = 04 and S_MONAT-HIGH = 06 i.e second quarter of 2007.

In this case mactual = mactual04mactual05mactual06 and likewise for mplan.

year-to-date-actual would be from MONAT = 01 to S_MONAT-HIGH, which here is S_MONAT-HIGH = 06

year-to-date-actual = mactual01 mactual02.....+mactual06.

Can anyone help me out with coding this? Points for sure!

Thanks,

MJ.