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: 

Function Module issue !!

Former Member
0 Kudos

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.

4 REPLIES 4

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

0 Kudos

Below MESSAGE IS COMING...

The statement "IMPORTING" is not expected. A correct similar statement is "IMPORT". .

WHAT CAN I DO NOW?

0 Kudos

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.