Application Development and Automation 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: 
Read only

Query on Event in Report program

Former Member
0 Likes
915

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

6 REPLIES 6
Read only

Former Member
0 Likes
726

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.

Read only

Former Member
0 Likes
726

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

Read only

Former Member
0 Likes
726

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

Read only

Former Member
0 Likes
726

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 .

Read only

Former Member
0 Likes
726

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

Read only

Former Member
0 Likes
726

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.