hi use this..
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,
venkat.
Try this in ur source code of FM.....include the import and Export...as given
*"----
""Local interface:
*" IMPORTING
*" REFERENCE(BEGDA) LIKE PA0001-BEGDA
*" REFERENCE(ENDDA) LIKE PA0001-ENDDA
*" EXPORTING
*" REFERENCE(DIFF_MONTHS) TYPE I
*" EXCEPTIONS
*" ENDDA_GRTR
*"----
DATA : SMONTH TYPE I,
EMONTH TYPE I,
SDATE TYPE I,
EDATE TYPE I,
SYEAR TYPE I,
EYEAR TYPE I,
MONTHSTOBEADDED TYPE I,
YRDIFF TYPE I,
DIFF TYPE I.
Calculating the months to be added
SMONTH = BEGDA+4(2).
EMONTH = ENDDA+4(2).
Finding the difference in years
SYEAR = BEGDA+0(4).
EYEAR = ENDDA+0(4).
IF SYEAR <> EYEAR .
SYEAR = SYEAR + 1.
DIFF = ( 12 - SMONTH ) + 1.
YRDIFF = EYEAR - SYEAR.
IF YRDIFF > 0 .
DIFF = DIFF + ( YRDIFF * 12 ).
ENDIF.
DIFF = DIFF + EMONTH.
ELSE.
DIFF = ( EMONTH - SMONTH ) + 1.
ENDIF.
DIFF_MONTHS = DIFF.
ENDFUNCTION.
DATA : w_months TYPE i.
u can give dates using variable also...i have hardcoded just for example...
CALL FUNCTION 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
EXPORTING
i_date_from = '20070101'
i_date_to = '20070205'
IMPORTING
e_months = w_months
.
WRITE : w_months.
rewards points if useful..
Sachin
Add a comment