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

How to create a default date

Former Member
0 Likes
1,542

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
Read only

Former Member
0 Likes
1,387

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
Read only

Sandeep_Panghal
Product and Topic Expert
Product and Topic Expert
0 Likes
1,387

Hi,

Use FM CONVERT_DATE_TO_INTERN_FORMAT --> Convert ddmmyyyy to yyyymmdd

Regards,

Sandeep

Read only

Former Member
0 Likes
1,388

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

Read only

Former Member
0 Likes
1,387

i cant put the outputed value in a parameter as default

Read only

0 Likes
1,387

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

Read only

0 Likes
1,387

Hi,

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

Regards,

Sandeep

Read only

0 Likes
1,387

Its simple .

PARAMETERS DATUM LIKE SY-DATUM DEFAULT '20081224'.

Read only

JozsefSzikszai
Active Contributor
0 Likes
1,387

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

Read only

Former Member
0 Likes
1,387

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

Read only

0 Likes
1,387

>

> 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.

Read only

0 Likes
1,387

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

Read only

Former Member
0 Likes
1,387

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

Read only

Former Member
0 Likes
1,387

ok

Read only

Former Member
0 Likes
1,387

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

Read only

Former Member
0 Likes
1,387

This message was moderated.