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 get number of periods between given range

Former Member
0 Kudos

Hi,

I am developing a program to insert new data into S716 table based on each period. The period range as given as input example 09/2005 to 02/2006. I have update the data for all the periods between the given range.

Is there any function module to get the no. of periods or a better logic to do this. pls help.

4 REPLIES 4

Former Member
0 Kudos

Hi Gopal,

1) Adding 01(day) to the second dates date and pass that to <b>RE_LAST_DAY_OF_MONTH or SLS_MISC_GET_LAST_DAY_OF_MONTH</b>. You will get the last date of that month(w_seconddate). Adding 01 will make first date(w_firstdate)

Then Days = w_seconddate - w_firstdate will give you the days.

Hope this helps you.

~thomas

Former Member
0 Kudos

HI,

Check the FM... "RKE_GET_NUMBER_OF_PERIODS".

Thanks and Regards,

Bharat Kumar Reddy.V

Former Member
0 Kudos

Hi,

Go thru this link

http://www.erpgenie.com/abap/functions.htm

Thanks

Sunil

anversha_s
Active Contributor
0 Kudos

Hi,

Sample code for the function module you want.

REPORT ZDATEDIFF.

DATA: EDAYS LIKE VTBBEWE-ATAGE,

EMONTHS LIKE VTBBEWE-ATAGE,

EYEARS LIKE VTBBEWE-ATAGE.

PARAMETERS: FROMDATE LIKE VTBBEWE-DBERVON,

TODATE LIKE VTBBEWE-DBERBIS DEFAULT SY-DATUM.

call function 'FIMA_DAYS_AND_MONTHS_AND_YEARS'

exporting

i_date_from = FROMDATE

i_date_to = TODATE

  • I_FLG_SEPARATE = ' '

IMPORTING

E_DAYS = EDAYS

E_MONTHS = EMONTHS

E_YEARS = EYEARS.

WRITE:/ 'Difference in Days ', EDAYS.

WRITE:/ 'Difference in Months ', EMONTHS.

WRITE:/ 'Difference in Years ', EYEARS.

INITIALIZATION.

FROMDATE = SY-DATUM - 60.

Regards,

anver

pls mark all hlpful answers