‎2008 Aug 24 9:59 AM
Hi experts,
I have used this function module "C14B_DIFF_BT_2_DATES" to find out the difference between the two dates.
I have declared two local variables as like in the function module for those two dates and fetched the no of the months in between those dates.
Here comes the problem while I am checking in function module individually in se37 its working fine. But while using this function module in my report the no. of months which is returning is not correct.
I have declared same as like that of in the function module but the values are not correct.Where is the actual error?
Thanks,
Sakthi
‎2008 Aug 24 10:11 AM
Hi
Check this Snippet
DATA :
w_d TYPE sy-datum,
w_d2 TYPE sy-datum,
w_days TYPE i,
w_months TYPE i,
w_years TYPE i.
w_d = '20080810'.
w_d2 = sy-datum .
CALL FUNCTION 'C14B_DIFF_BT_2_DATES'
EXPORTING
i_date_from = w_d
i_date_to = w_d2
IMPORTING
e_days = w_days
e_months = w_months
e_years = w_years
EXCEPTIONS
plausibility_check_failed = 1.
WRITE /:
w_days,
w_months,
w_years.output is 14regards
Pavan
‎2008 Aug 24 10:10 AM
Hi Sakti,
Please replace ur FM with below FM. It will work perfectly.
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.Regards,
Anversha
‎2008 Aug 24 10:11 AM
Hi
Check this Snippet
DATA :
w_d TYPE sy-datum,
w_d2 TYPE sy-datum,
w_days TYPE i,
w_months TYPE i,
w_years TYPE i.
w_d = '20080810'.
w_d2 = sy-datum .
CALL FUNCTION 'C14B_DIFF_BT_2_DATES'
EXPORTING
i_date_from = w_d
i_date_to = w_d2
IMPORTING
e_days = w_days
e_months = w_months
e_years = w_years
EXCEPTIONS
plausibility_check_failed = 1.
WRITE /:
w_days,
w_months,
w_years.output is 14regards
Pavan
‎2008 Aug 24 10:12 AM
it is working fine, error lies in your code.
add 1 day extra to the i_date_to and see ..
check this code..
REPORT ZTEST_DATE_DIIF.
data: i_date_from type sy-datum,
i_date_to type sy-datum.
data: e_days type i,
e_months type i,
e_years type i.
i_date_to = '20090101'.
i_date_from = '20080101'.
CALL FUNCTION 'C14B_DIFF_BT_2_DATES'
EXPORTING
i_date_from = i_date_from
i_date_to = i_date_to
IMPORTING
E_DAYS = E_DAYS
E_MONTHS = E_MONTHS
E_YEARS = E_YEARS
EXCEPTIONS
PLAUSIBILITY_CHECK_FAILED = 1
.
write:/ e_days, e_months, e_years.
‎2008 Aug 24 10:20 AM
Problem Solved.
Thanks for all your answers.
Hope you received your valuable points.
Regards,
Sakthi