‎2006 Jun 20 4:07 PM
Hi Experts,
I have a select-option element for date. I have mapped it to type SY-DATUM.
When i run the selection screen, and try to give a junk date, the system generating an error: Enter date in format: __/__/____.
I want to my custom error message : Enter date in format: MM/DD/YYYY.
1. So how to override the system error?
One more thing, in SAP the date format depends on the format specified in the user's profile. So if a user with date format DD.MM.YYYY runs my program then he will get a message:Enter date in format: __.__.____
2. So how to get the user's date format and dynamically update the format in the comment statement. SELECTION-SCREEN COMMENT /32(50) 'DD/MM/YYYY'.
Thanks
Gopal
‎2006 Jun 20 4:14 PM
First, that message is from message class 00 and message number 65. Notice that it has a variable for the format. I beleive this will be filled by the formatting of the user specific setting. So, just changing the message is not going to help here. Looks like you will need to use another field type and handle it manually.
Also you can get the user setting from USR01.
data: xusr01 type usr01.
select single * from usr01 into xusr01
where bname = sy-uname.
*1 DD.MM.YYYY
*2 MM/DD/YYYY
*3 MM-DD-YYYY
*4 YYYY.MM.DD
*5 YYYY/MM/DD
*6 YYYY-MM-DD
case xusr01-datfm.
when '1'.
when '2'.
when '3'.
when '4'.
when '5'.
when '6'.
endcase.Regards,
Rich Heilman
‎2006 Jun 20 4:17 PM
It gives you date fromat from user profile ( tr.SU3)
RETRIEVE USER PROFILE DATE SETTING
select single datfm
into user_set
from usr01
where bname = sy-uname.
Just check it and give error message ...
Hope thisll give you idea!!
<b>Pl... award the points.</b>
Good luck
Thanks
Saquib Khan
"Some are wise and some are otherwise"
‎2006 Jun 20 4:27 PM
You can fill your comment with the current user specific format in this way. Here we are getting the text from the domain.
report zrich_0001.
select-options: s_datum for sy-datum.
selection-screen comment /32(20) dt_fmt.
at selection-screen output.
data: xusr01 type usr01.
data: idd07v type table of dd07v with header line.
select single * from usr01 into xusr01
where bname = sy-uname.
*1 DD.MM.YYYY
*2 MM/DD/YYYY
*3 MM-DD-YYYY
*4 YYYY.MM.DD
*5 YYYY/MM/DD
*6 YYYY-MM-DD
call function 'DD_DOMVALUES_GET'
exporting
domname = 'XUDATFM'
text = 'X'
langu = sy-langu
tables
dd07v_tab = idd07v
exceptions
wrong_textflag = 1
others = 2.
read table idd07v with key DOMVALUE_L = xusr01-datfm.
if sy-subrc = 0.
dt_fmt = idd07v-ddtext.
endif.
Regards,
Rich Heilman
‎2006 Jun 20 4:45 PM
Hello Gopal,
Here is the sample code.
DATA: lv_value TYPE domvalue_l,
ls_usr01 TYPE usr01,
ls_dd07v TYPE dd07v.
SELECTION-SCREEN BEGIN OF BLOCK TEST.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(18) lv_text
FOR FIELD s_date.
SELECT-OPTIONS s_date FOR sy-datum.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK TEST.
INITIALIZATION.
Get date format code from user profile
CALL FUNCTION 'CETA_USR01_READ'
EXPORTING
BNAME = sy-uname
IMPORTING
USR01_EXP = ls_usr01
EXCEPTIONS
NO_ENTRY = 1
OTHERS = 2.
Get the date format text
lv_value = ls_usr01-datfm.
CALL FUNCTION 'DD_DOMVALUE_TEXT_GET'
EXPORTING
DOMNAME = 'XUDATFM'
VALUE = lv_value
IMPORTING
DD07V_WA = ls_dd07v.
lv_text = ls_dd07v-ddtext.
CONCATENATE 'Date' ' (' lv_text ')' INTO lv_text.
Reward points if it helps...
Priya
‎2006 Jun 21 5:27 AM
Hi,
I still did not get the aswer for how to override system error?
I have written a sample subroutine to check format is valid or not. But before this subroutine gets fired system is generating its error message: Enter date format in: __/__/____. I am calling my subroutine in
at selection-screen event and on pressing "execute" button.
So my question is how to override this system error with my own custom message.
Thanks
Gopal