05-01-2009 10:07 AM
Dear All,
I am using the fuction module /SDF/CMO_DATETIME_DIFFERENCE to calculate the diffence days between 2 dates.Here i am want to write the difference days as output? How to import and write the DIFFDAYS? my code is as below.
&----
*& Report ZTESTMAIN
*&
&----
*&
*&
&----
Report 556.
Parameters:p_frdate type d,
p_todate type d.
data: date1 type d,
date2 type d.
data: datediff type d.
date1 = p_frdate.
date2 = p_todate.
CALL FUNCTION '/SDF/CMO_DATETIME_DIFFERENCE'
EXPORTING
DATE1 = date1
TIME1 =
DATE2 = date2
TIME2 =
IMPORTING
DATEDIFF = datediff
TIMEDIFF =
EARLIEST =
EXCEPTIONS
INVALID_DATETIME = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION '/SDF/CMO_DATETIME_DIFFERENCE'
EXPORTING
DATE1 = p_frdate.
TIME1 =
DATE2 = p_todate.
TIME2 =
IMPORTing
DAteDIFF = datediff
TIMEDIFF =
EARLIEST =
EXCEPTIONS
INVALID_DATETIME = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
*
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Write : / datediff.
Write is not working here PLEASE SUGGEST ME HOW TO DO THIS?
Thanks & Regards,
Murali.
05-01-2009 10:12 AM
hi
take a varibale of type string and assign the value to it and try to display.
Hope this will surely solve your problem.
Cheers
Suvendu
05-01-2009 10:15 AM
Hi,
In Fm DATEDIFF is of type P..Change the declaaration in your program..
Change the declaration to P from D
data: datediff type d. " Change to P as below
DATA: datediff TYPE p.
05-01-2009 10:19 AM
Below MESSAGE IS COMING...
The statement "IMPORTING" is not expected. A correct similar statement is "IMPORT". .
WHAT CAN I DO NOW?
05-02-2009 11:11 AM
Change the type of datediff from d to p.
U have written : if sy-subrc 0.
It shd be: if sy-subrc = 0.
After changing this ur code is working perfect on my system.