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: 

Reg function module

Former Member
0 Kudos

Hi,

I am working on function module. my requirement is if i will give from date and to date out put will be in no of days.

Regards

Srinu

7 REPLIES 7

Former Member
0 Kudos

Hi Sreenivas,

Just calculate the difference between two dates using arithmetic subtract operator.

DATA V_DAYS TYPE I.

V_DAYS = TO_DATE - FROM_DATE.

Give the TO_DATE and FROM_DATE to the function module as IMPORT parameters and calculate the difference in the source code and display the difference using WRITE statement.

Thanks,

Vinay

Former Member
0 Kudos

hi

DATA: To_date type sy-datum,

From_date type sy-datum,

days type i.

days = To_date - From_date + 1.

Write:/ 'The no of days :', days.

Former Member
0 Kudos

hi

U can use DAYS_BETWEEN_TWO_DATES.

Sample :

REPORT ZEXAMPLE.

DATA V_DIFF TYPE I.

PARAMETERS P_BIRTHD LIKE SY-DATUM.

CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'

EXPORTING

I_DATUM_BIS = SY-DATUM

I_DATUM_VON = P_BIRTHD

IMPORTING

E_TAGE = V_DIFF

EXCEPTIONS

DAYS_METHOD_NOT_DEFINED = 1

OTHERS = 2.

<b>

reward points for useful ans</b>

regards

Aarti

0 Kudos

Hi arthi,

i created function module in the se37. i given import parameters date1 and date.Export parameter no_days.In the source code tab i writen foloing code.

IF DATE1 < DATE2.
RAISE V_EXC.

NO_DAYS = DATE1 - DATE2.
ENDIF.

ENDFUNCTION.

Regards

Srinu

Former Member
0 Kudos

hi! sreenivaslu

can do by getting

1. FROM_DATE and TO_DATE in Import parameters.

2. subtract using Arithmetic Operator

date1 = to_date - from_date.

this will give you the difference of dates which you want

3. can display this value in EXPORT Parameter.

(OR)

Using the Function Module DAYS_BETWEEN_TWO_DATES

1. Pass the From and To dates as Input

2. Get the day to a variable

3. Pass this variable as the EXPORT Parameters variable.

CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'

EXPORTING

I_DATUM_BIS = TO_DATE

I_DATUM_VON = FROM_DATE

IMPORTING

E_TAGE = DATE

Reagrds,

Nagulan

Reward me if its Useful.

Former Member
0 Kudos

hi,

try using :

FIMA_DAYS_AND_MONTHS_AND_YEARS : Find the difference between two dates in years, months and days.

or

HR_99S_INTERVAL_BETWEEN_DATES : Difference between two dates in days, weeks, months

might be useful..

regrads,

ritika malhotra

Message was edited by:

ritika malhotra

Former Member
0 Kudos

Use the standard function module as suggested by others. If your problem is solved, please close this thread.