2009 Jan 14 5:56 PM
Hi all,
I have a requirement to validate the date entered on the selection screen of a Report progam.
The validation needs to be done is that whether the date is less than today's date...If the date is a future date then an error message needs to be displayed and the program should not execute.
The validation of the date must be done when the user clicks on execute button / when the user saves the selection screen by cicking save button / when the user presses enter.
Please provide me some pointers on the above.
Regards,
Vijay
2009 Jan 14 6:08 PM
Hi,
Try this code
" P_date is the selection screen field.
AT SELECTION-SCREEN ON p_date.
IF P_DATE GT SY-DATUM.
MESSAGE e058(00) WITH 'Please enter the data greater than today's date'
ENDIF.
2009 Jan 15 4:29 AM
HI ,
Addon to the above code u have to use below mentioned code as well if u want the error message on save button as well:-
maintain the PF status for the button SAVE with the name SAVE.
data : ucomm type sy-ucomm.
ucomm = sy-ucomm.
Case ucomm.
when 'SAVE'.
if p_date gt sy_datum.
error message.
endif.
Thanks & Regards
Ruchi Tiwari
2009 Jan 15 4:40 AM
small tip........IF P_DATE GT SY-DATUM.----
> this will work, provided the p_date declaration with an DATE type field, like p_date type sy-datum or p_date type bkpf-budat etc.....otherwise, u hv to go to FMs to compare the dates.
thanq
2009 Jan 15 4:50 AM
Hi ,
Whenever you click on selection screen the event AT SELECTION-SCREEN is called ,
so under that event you can validate your date logic .
example :
PARAMETER : DATE TYPE SY-DATUM .
AT SELECTION-SCREEN ON DATE . " THIS IS EVENT USED FOR VALIDATE PARTICULAR FIELD
IF DATE GT SY-DATUM .
MESSAGE E000(00) WITH 'Please enter valid date , it should not greater than current date' .
ENDIF .
Your prob. will solved definately .
REGARDS
NILESH JAIN .
2009 Jan 15 4:52 AM
Hi,
You need to use AT SELECTION-SCREEN event to validate it.
That means under this event you need to check if the value of select-option or parameter is GT sy-datum.
then display the message accorndingly.
AT selection-screen on <para>.
If <para> LT sy-datum.
message.
endat.
hope it will help you.
Regards,
Rajesh Kumar
2009 Jan 15 4:57 AM
Hi,
The following code will definitely help u.
PARAMETER: date TYPE sy-datum.
AT SELECTION-SCREEN on date.
IF date gt sy-datum.
MESSAGE 'Date should be less than or equals to today date' TYPE 'E'.
ENDIF.
Thanks.