Application Development and Automation 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: 
Read only

Function module to add days to current date

Former Member
62,310

Hi All,

Can any one specify the function module to add days to current date?

e.g. if i add 7 days to 31st Jan, it should come as 7th feb, not 38 .

Plz specify with example.

7 REPLIES 7
Read only

Former Member
18,073

Hi

You can simply add the days to date as:

data: date1 like sy-datum, date2 like datum.

date2 = sy-datum + 10.

write: / date2.

it gives after 10 days date

Regards

Anji

Read only

Former Member
0 Likes
18,073

Hi, Debarshi.

It's no need to use FM, you can add days directly.

for example,

data now type d value '20070131'.

now = now + 7.

Regards,

feng.

Read only

Sathish
Product and Topic Expert
Product and Topic Expert
0 Likes
18,073

Its easy to write a new Function Module!!

I remember writing a new function module some time back to convert Fiscal Year to Calendar Year & Month.

Read only

Former Member
0 Likes
18,073

no need of FM,

if the variable type is sy-datum system will automatically do this task when u add simply

Read only

former_member386202
Active Contributor
0 Likes
18,073

Hi

refer this

CALL FUNCTION 'RE_ADD_MONTH_TO_DATE'

EXPORTING

months = '2'

olddate = lv_date

IMPORTING

newdate = lv_newdate.

regards,

Prashant

Read only

Former Member
0 Likes
18,073

Hi,

Use following function module (ADD_TIME_TO_DATE) for your requirement.

DATA : F_DATE  LIKE  SY-DATUM,

       T_DATE  LIKE  SY-DATUM,

       V_IPRKZ LIKE  MARA-IPRKZ.

V_IPRKZ = 'D'.

F_DATE = '20120509'.

* Convert to Internal Representation

CALL FUNCTION 'CONVERSION_EXIT_PERKZ_INPUT'

    EXPORTING

          INPUT  = V_IPRKZ

     IMPORTING

          OUTPUT = V_IPRKZ.

CALL FUNCTION 'ADD_TIME_TO_DATE'

  EXPORTING

    I_IDATE  = F_DATE " Your Original Date Here

    I_TIME   = 5 " No.of Days or Months or Years you want to add to Given date

    I_IPRKZ  = V_IPRKZ " Indicator D = Days M = Months Y = Years

*   I_RDMHD   =

  IMPORTING

    O_IDATE  = T_DATE      " Processed Date

.

in above example,

I_TIME  = 5

I_IPRKZ = 'D'

So, it will add 5 days to given date.


-Thanks,

Chintan

Read only

0 Likes
18,073

Please do not use D M Y for the field I_IPRKZ.

the proper amounts are

blank(for day), 1 (for week), 2 (for month), 3 (for year)