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 field on Selection Screen

Former Member
0 Likes
7,180

Hi All,

I need to create Date field (From and To) in the selection screen. The Date format should appear as YYYY-MM-DD.

I have defined this requirement as below.

select-options: s_date for sy-datum no-extension default sy-datum.

Due to above line, date is appearing in DD.MM.YYYY format.

How to code, so that date should appear in YYYY-MM-DD in the selection screen...????

Please Help me....

Regards

Pavan

Hi All,

I need to create Date field (From and To) in the selection screen. The Date format should appear as YYYY-MM-DD.

I have defined this requirement as below.

select-options: s_date for sy-datum no-extension default sy-datum.

Due to above line, date is appearing in DD.MM.YYYY format.

How to code, so that date should appear in YYYY-MM-DD in the selection screen...????

Please Help me....

Regards

Pavan

5 REPLIES 5
Read only

amit_khare
Active Contributor
0 Likes
3,353

Hi,

Date format depends on the user settings so vary from user to user unless they are predefined by the Basis team and are blocked for user changes.

So as an alternative you may change the date after user enter it to your desired format, by that you can save your program against user profile changes.

You can smple do that by using WRITE statement with masking.

Regards,

Amit

Reward all helpful replies.

Read only

Former Member
0 Likes
3,353

Pavan,

write below code.

DATA : WS_DATE like sy-datum.

select-options: s_date for sy-datum.

AT SELECTION SCREEN OUTPUT.

call function 'CONVERT_DATE_TO_INTERN_FORMAT'

exporting

datum = sy-datum

dtype = 'DATS'

  • IMPORTING

  • ERROR =

IDATE = ws_date.

  • MESSG =

  • MSGLN =

.

s_date-low = ws_date.

Pls. reward if useful

Read only

Former Member
0 Likes
3,353

Thanks

Read only

Former Member
0 Likes
3,353

Pavan,

DATA : WS_DATE(10),

ws_day(2),

ws_mon(2),

ws_year(4).

tables : ADAA.

select-options: s_date FOR ADAA-ACTION.

INITIALIZATION.

ws_year = sy-datum+0(4).

ws_mon = sy-datum+4(2).

ws_day = sy-datum+6(2).

concatenate ws_year ws_mon ws_day into ws_date separated by '.'.

s_date-low = ws_date.

append s_date.

This is working fine.

Pls reward.

Read only

Former Member
0 Likes
3,353

Hi Pavan,

You have to specify this in the user settings only.

Initialization u cant specify this.

Other than that if u want the same format to be used in the program u can convert that using the belwo code

 v_month = fromdate-low+4(2).
 v_year = fromdate-low+0(4).
 v_days = fromdate-low+6(2).
 CONCATENATE v_year '-' v_month '-' v_days  INTO fromdate-low.

And use whereevr needed but cant be shown in the screen.