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: 

How to select Months with in a date range

Former Member
0 Kudos

Hi

I am working on a report which will list out Month wise totals in each row.

How should i select the Months with in a date range and do the sum ( User may select the date range for N number of years also. Example : 01/10/2000 to 01/01/2010 )

Thanks in advance

Thanks&regards

Mrudula

4 REPLIES 4

sreeramkumar_madisetty
Active Contributor
0 Kudos

Hi

Use the following code:

data: l_date(8) value '03042007',

l_mname type t247-ktx,

l_c(25).

select single ktx from t247

into l_mname

where spras = sy-langu

and mnr = l_date+2(2).

concatenate l_mname l_date+6(2)

into l_c." SEPARATED BY space.

data: g_date(10) type c. " Processing date of Report

g_date = sy-datum.

concatenate g_date0(4) g_date4(2) g_date+6(2) into g_date.

data: g_date1(10) type c.

g_date1 = so_verab-high.

concatenate g_date10(4) g_date14(2) g_date1+6(2) into g_date1.

Regards,

Sreeram

Former Member

Former Member
0 Kudos

If user is entering date in specified / System format then simply take the MMYYYY from the date value of both Starting & Ending. Then Bifurcate each month starting from first then increasing by one , when reaching 12 the next increase MM = 1 and YYYY increase it by 1. Append this to an internal table. You have the monthly range you required. I hope this helps you.

Now based on this you can bifurcate you data also. If you want the code do tell me.

Raj

Former Member
0 Kudos

Hi,

You have to segregate the months from the Data range entered on sel screen and have to display the related sums

like If date+4(2) = '01' January

If date+4(2) = '02' February

Or you can use the MONAT will be there in finance tables) field for periods to calculate the sums.

reward if useful

regards,

ANJI