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: 

Date format

Former Member
0 Kudos

Hi Experts,

My requirement is as below.

On selection screen select options date is expected in a certain format MM/DD/YYYY. but for new design I want to make it work dynamically, that the program works for all date formats based on user settings.

it should be like making select options dynamic so that it would accept

any date format and pass it to system date format.

is there any logic or Function module to convert select-options date to system date format. system accepts date in sy-datum i.e. yyyymmdd.

Please let me know if thre is something FM or logic.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Yogesh

If my understanding is correct, the user enter the date with respect to his/her own profile format and you need to get the date into a variable in format yyyymmdd.

We can do this by using table <b>USR01</b> and FM: <b>DATE_STRING_CONVERT</b>.

Field DATFM of table USR01 will give the format set in user's profile. Pass this and the date entered in the selection-screen to FM.

Below sample code can help you understand the same:

parameters: p_format type XUDATFM,
            p_date(10) type c.
data: date type datum.

CALL FUNCTION 'DATE_STRING_CONVERT'
  EXPORTING
    DATE_FORMAT       = p_format
    DATE_STRING       = p_date
*   START_DATE        = SY-DATUM
 IMPORTING
   RESULT_DATE       = date.

write:/ date.

break-point.

Check the value in date when the break point is reached.

Hope this helps.

Kind Regards

Eswar

1 REPLY 1

Former Member
0 Kudos

Hi Yogesh

If my understanding is correct, the user enter the date with respect to his/her own profile format and you need to get the date into a variable in format yyyymmdd.

We can do this by using table <b>USR01</b> and FM: <b>DATE_STRING_CONVERT</b>.

Field DATFM of table USR01 will give the format set in user's profile. Pass this and the date entered in the selection-screen to FM.

Below sample code can help you understand the same:

parameters: p_format type XUDATFM,
            p_date(10) type c.
data: date type datum.

CALL FUNCTION 'DATE_STRING_CONVERT'
  EXPORTING
    DATE_FORMAT       = p_format
    DATE_STRING       = p_date
*   START_DATE        = SY-DATUM
 IMPORTING
   RESULT_DATE       = date.

write:/ date.

break-point.

Check the value in date when the break point is reached.

Hope this helps.

Kind Regards

Eswar