‎2007 Jul 20 3:19 PM
Hi
I am new to all this..so pls help me with this...
I need to validate my input field in the selection screen to have the format as YYYYMMDD i.e user is allowed to enter the date in this format only!!
Now how to validate this kind of a format??
‎2007 Jul 20 3:23 PM
Hi,
Declare the date field in reference to Sy-datum.
Data p_date type sy-datum.
<b>Reward if helpful.</b>
‎2007 Jul 20 3:24 PM
‎2007 Jul 20 3:25 PM
Hi
That's INPUT format just one used to save a date, so u need to check it only.
It's the same if you used a DATS format, because its INPUT FORMAT is the same, for example, output format of SY-DATUM is DD.MM.YYYY, but input format is YYYYMMDD, so:
PARAMATERS: P_DATE LIKE SY-DATUM.
AT SELECTION-SCREEN.
IF P_DATE < SY-DATUM.
MESSAGE E208(00) 'Error'.
ENDIF.
In your case the INPUT and OUTPUT format are the same so:
PARAMATERS: P_DATE(8) TYPE N.
AT SELECTION-SCREEN.
IF P_DATE < SY-DATUM.
MESSAGE E208(00) 'Error'.
ENDIF.
Max
‎2007 Jul 20 3:35 PM
thanks for the quick response!!
one thing i want to add more is that if i make it as sy-datum then thew error msg i get (in case when the format entered is wrong is as:
Enter date in the format _ / _ /_ _ _ _
but what i want is YYYYMMDD
‎2007 Jul 20 3:40 PM
For this you have to change the usre profile attributes.
Go to transaction SU3 - in that default tab select your date format.
Reward if helpful.
‎2007 Jul 20 3:47 PM
‎2007 Jul 20 3:57 PM
can we display error msg without creating any message class??
‎2007 Jul 20 3:31 PM
LV_DAY = SY-DATUM+6(2).
LV_MON = SY-DATUM+4(2).
LV_YEAR = SY-DATUM+0(4).
in place of sy-datum you can take the date of your requirement.
verify that lv_day <= 31
and lv_month <= 12.
regards,
srinivas
<b>*reward for useful answers*</b>
‎2007 Jul 20 3:46 PM
thanks i think ur solution will work the best!!
one more thing ..can we display error msg without creating any message class??
‎2007 Jul 20 3:49 PM
Hi,
Write the below code in the INITIALIZATION event.
data: OLD_DATE TYPE SY-DATUM,
NEW_DATE(10).
OLD_DATE = SY-DATUM.
CONCATENATE OLD_DATE0(4) '/' OLD_DATE4(2) '/' OLD_DATE+6(2) INTO
NEW_DATE.
write:/ 'OLD DATE:', old_date,
/ 'NEW_DATE:', new_date.
‎2007 Jul 20 3:54 PM
Hi,
Try this way by using SAP standard message class
message e398(00) with 'Testing'.
aRs
‎2007 Jul 20 4:02 PM
Hi,
Here in above example you have not created any message class. you are using sAP standard message class 00 and and its message number 398. Here message number 398 have 4 place holders (ie & & & & ) so you can pass 4 texts to shows as message
Otherwise if you want to display a message without using message statement then
use function module
POPUP_TO_INFORM.
aRs