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

date issue

Former Member
0 Likes
2,052

hi folks,

g_startdate like sy-datum

g_enddate like sy-datum.

call function 'RP_CALC_DATE_IN_INTERVAL'

exporting

date = g_startdate

days = 1

months = 0

signum = '-'

years = 0

importing

calc_date = g_enddate.

I am trying to get the previous day of the startdate using this FM and I am unable to get that.

can anyone tell me what am I doing wrong here?

Thanks

Vinu

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,005

Hi Vinu,

a lot of answers for your thread.

Does no answer solve your problem?

Regards, Dieter

16 REPLIES 16
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
2,005

Working fine for me.




report zrich_0001.

data: g_startdate type sy-datum,
      g_enddate   type sy-datum.

g_startdate = sy-datum.

call function 'RP_CALC_DATE_IN_INTERVAL'
     exporting
          date      = g_startdate
          days      = 1
          months    = 0
          signum    = '-'
          years     = 0
     importing
          calc_date = g_enddate.


write:/ g_enddate.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
2,005

hi vinu,

it does work for me.

DATA:G_STArtdate like sy-datum,

g_enddate like sy-datum.

G_STARTDATE = SY-DATUM.

call function 'RP_CALC_DATE_IN_INTERVAL'

exporting

date = g_startdate

days = 1

months = 0

signum = '-'

years = 0

importing

calc_date = g_enddate.

WRITE: G_ENDDATE.

Read only

Former Member
0 Likes
2,005

Hi vinu,

you can try this:

data: g_startdate like sy-datum.

data: g_enddate like sy-datum.

g_startdate = sy-datum.

g_enddate = g_startdate - 1.

write: / g_startdate, g_enddate.

g_startdate = sy-datum.

g_enddate = g_startdate + 1.

write: / g_startdate, g_enddate.

You don't need an FM.

Regards, Dieter

Read only

0 Likes
2,005

I know it is simple

here is what i wrote in the code...

g_startdate = itab-begda.

call function 'RP_CALC_DATE_IN_INTERVAL'

exporting =

date = g_startdate

days = 1

months = 0

signum = '-'

years = 0

importing

calc_date = g_enddate.

I do get the start date as 11122006 in the field but g_enddate is 00000000.

I am wondering what am I missing?

Thanks

Vinu

Read only

0 Likes
2,005

Hi Vinu,

your moving is wrong.

try this:

data: g_startdate like sy-datum.

data: g_enddate like sy-datum.

g_startdate = '20061112'.

g_enddate = g_startdate - 1.

write: / g_startdate, g_enddate.

g_startdate = '20061112'.

g_enddate = g_startdate + 1.

write: / g_startdate, g_enddate.

Regards, Dieter

Read only

0 Likes
2,005

Hi Vinu,

your moving is wrong.

try this:

data: g_startdate like sy-datum.

data: g_enddate like sy-datum.

g_startdate = '20061112'.

g_enddate = g_startdate - 1.

write: / g_startdate, g_enddate.

g_startdate = '20061112'.

g_enddate = g_startdate + 1.

write: / g_startdate, g_enddate.

Regards, Dieter

Read only

0 Likes
2,005

Hi Vinu,

The system date format is always "YYYYMMDD". but in your case, you are using "ddmmyyyy". I guess that that is why you are getting 0's. Try this out.

Regards

Raghav

Read only

0 Likes
2,005

dear if you want use like that format convert your date with follows

DATA: V_DATE LIKE SY-DATUM,

V_DATE2(10).

CALL FUNCTION 'CONVERT_DATE_INPUT'

EXPORTING

INPUT = '21102002' "DD.MM.YYYY

PLAUSIBILITY_CHECK = 'X'

IMPORTING

OUTPUT = V_DATE "YYYY.MM.DD

EXCEPTIONS

PLAUSIBILITY_CHECK_FAILED = 1

WRONG_FORMAT_IN_INPUT = 2

OTHERS = 3.

V_DATE2 = V_DATE.

WRITE:/ V_DATE2.

Read only

ferry_lianto
Active Contributor
0 Likes
2,005

Hi Vinu,

Perhaps field G_STARTDATE is empty.

Try to assign SY-DATUM to field G_STARTDATE.

G_STARTDATE = SY-DATUM.

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
2,005

Hi Vinu .

Why do you want to use a FM just ti get the previous date .

Just substract from the current date , you will get the result.



Data : v_one type sy-datum.

start-of-selection.
v_one = sy-datum.
write:/ v_one.

v_one = v_one - 1 .
write:/ v_one.

Regards

Arun

Read only

Former Member
0 Likes
2,005

execute this code

data : begin of itab occurs 0,
       begda like sy-datum,
       preda like sy-datum,
       end of itab.

ata :  g_startdate like sy-datum,
       g_enddate like sy-datum.


       itab-begda = sy-datum.
       append itab.


       loop at itab.

       g_startdate = itab-begda.

       CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
         EXPORTING
         date            =  g_startdate
         days            =  01
         months          =  00
         SIGNUM           = '-'
         years           = 00
       IMPORTING
        CALC_DATE       =   g_enddate.

       endloop.



       write:/ 'prev date', g_enddate.

regards,

vijay.

Read only

Former Member
0 Likes
2,005

Hi Vinu,

You may be forgot to assign the date to g_startdate.Please try with the following code:

g_startdate like sy-datum

g_enddate like sy-datum.

g_startdate = sy-datum. "Assigns the current date

call function 'RP_CALC_DATE_IN_INTERVAL'

exporting

date = g_startdate

days = 1

months = 0

signum = '-'

years = 0

importing

calc_date = g_enddate.

Hope, you will get the desired result.

Read only

Former Member
0 Likes
2,006

Hi Vinu,

a lot of answers for your thread.

Does no answer solve your problem?

Regards, Dieter

Read only

Former Member
0 Likes
2,005

u want previous day date...

g_enddate = g_startdate - 1.

Read only

Former Member
0 Likes
2,005

Hi Vinu,

Please drop the previous reply as I haven't seen the reply made by you.

The actual problem is in the date format for itab-begda.You need to change it into internal format and the function module can be used for that.

CALL FUNCTION 'CONVERT_DATE_TO_INTERN_FORMAT'

EXPORTING

DATUM = itab-begda.

DTYPE = 'DATS'

IMPORTING

  • ERROR =

IDATE = g_startdate

  • MESSG =

  • MSGLN =

Please check it & revert if any.

Regards,

Selvakumar K.

Read only

0 Likes
2,005

Appreciaste your help guys. Thanks I shall award the points accordingly.

Vinu