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: 

How to create a default date

Former Member
0 Kudos

How can a create a default date from SY-datum that will give a date with a format like YYYYMMDD?

Edited by: Alvin Rosales on Oct 16, 2008 10:47 AM

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Alvin

Try this code

DATA : DATE TYPE CHAR10.

CALL FUNCTION 'FORMAT_DATE_4_OUTPUT'
  EXPORTING
    DATIN         = SY-DATUM
    FORMAT        = 'YYYYMMDD'
 IMPORTING
   DATEX         = DATE
          .

WRITE : / DATE.

Regards

14 REPLIES 14

Sandeep_Kumar
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

Use FM CONVERT_DATE_TO_INTERN_FORMAT --> Convert ddmmyyyy to yyyymmdd

Regards,

Sandeep

Former Member
0 Kudos

Hi Alvin

Try this code

DATA : DATE TYPE CHAR10.

CALL FUNCTION 'FORMAT_DATE_4_OUTPUT'
  EXPORTING
    DATIN         = SY-DATUM
    FORMAT        = 'YYYYMMDD'
 IMPORTING
   DATEX         = DATE
          .

WRITE : / DATE.

Regards

Former Member
0 Kudos

i cant put the outputed value in a parameter as default

0 Kudos

Hi,

I did not understand your question properly. But if you want to put default date try this.

PARAMETERS : P_DATE TYPE CHAR20 DEFAULT SY-DATUM.

Regards

Sandeep_Kumar
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

Yes u can make this date as default under INITIALIZATION event.

Regards,

Sandeep

0 Kudos

Its simple .

PARAMETERS DATUM LIKE SY-DATUM DEFAULT '20081224'.

JozsefSzikszai
Active Contributor
0 Kudos

I don't understand what is the problem here... sy-datum has actually format like YYYYMMDD

Former Member
0 Kudos

CALL FUNCTION 'FORMAT_DATE_4_OUTPUT'

EXPORTING

datin = sy-datum

format = 'YYYYMMDD'

IMPORTING

datex = v_date.

this is a goood answer but i cant place the v_date into the parameters at selection screen, the value of vdate doesnt appear in the selection screen

0 Kudos

>

> CALL FUNCTION 'FORMAT_DATE_4_OUTPUT'

> EXPORTING

> datin = sy-datum

> format = 'YYYYMMDD'

> IMPORTING

> datex = v_date.

>

> this is a goood answer but i cant place the v_date into the parameters at selection screen, the value of vdate doesnt appear in the selection screen

actually the above code does not change anything, just waste of time (told already that the format of sy-datum is YYYYMMDD), you only need:

PARAMETERS : p_date TYPE sy-datum DEFAULT sy-datum.

0 Kudos

Hi Alvin,

I think this solves the problem right?

PARAMETERS : P_DATE TYPE CHAR20 DEFAULT SY-DATUM.

Have you tried it ?

Regards

Edited by: Rajvansh Ravi on Oct 16, 2008 11:24 AM

Former Member
0 Kudos

Hi, Alvin, i just want to say format of sy-datum is yyyymmdd if you do not use the statement 'Write' to output.

Former Member
0 Kudos

ok

Former Member
0 Kudos

hi this will work ..

parameters : ss(8) type c .

initialization.

CALL FUNCTION 'CONVERT_DATE_TO_INTERN_FORMAT'

EXPORTING

datum = sy-datum

dtype = 'YYYYDDMM'

IMPORTING

  • ERROR =

IDATE = ss.

  • MESSG =

  • MSGLN =

YOU CAN USE ANOTHER OPTION.

parameters : ss(8) type c default sy-datum.

Edited by: swati gupta on Oct 16, 2008 11:29 AM

Former Member
0 Kudos

This message was moderated.