01-10-2007 5:12 AM
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.
01-10-2007 5:37 AM
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
01-10-2007 5:37 AM
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