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

Validating the input

Former Member
0 Likes
946

Hi friends,

I want to throw an error message when user enters in date field.My requirement is to restrict the user to enter only first day of the future months like 01.10.2009 or 01.12.2010...........not like 02.05.2009.

how to do it?

Thanks.

8 REPLIES 8
Read only

Former Member
0 Likes
907

Hi,

Welcome to SDN.

Try this code.


parameter w_date like sy-datum.
At selection-screen.
if w_date+6(2) NE '01'.
message 'Enter the first day of the month' type 'E'.
endif.

to check the whole future date

PARAMETERS: p_date LIKE sy-datum.

AT SELECTION-SCREEN.
  IF p_date+6(2) <> '01'.
    MESSAGE 'enter' TYPE 'E'.
  ELSEIF p_date+0(4) < sy-datum+0(4).
    MESSAGE 'wrong' TYPE 'E'.
  ELSEIF p_date+4(2) < sy-datum+4(2).
    MESSAGE 'Enter future month' TYPE 'E'.
  ENDIF.

Thanks&Regards

Sarves

Read only

rainer_hbenthal
Active Contributor
0 Likes
907

Check the input at event AT SELECTION-SCREEN ON P_DATE.

Read only

Former Member
0 Likes
907

IF P_DATE+0(2) NE '01'

ERROR.

ENDIF.

Read only

0 Likes
907

not only date...i should also see the month & year because it should be only future date.

Thanks.

Read only

0 Likes
907

>

> not only date...i should also see the month & year because it should be only future date.

>

>

>

> Thanks.

Thats an easy task for an programmer, just code it for your own.

Read only

Former Member
0 Likes
907

hi

Check this

PARAMETERS: s_name TYPE ERSDA.

if s_name <= sy-datum .

MESSAGE 'Error' TYPE 'I'.

Else.

MESSAGE 'Sucess' TYPE 'I'.

endif.

Thanks

Read only

0 Likes
907

Hi.. please use the below code.

parameters : p_date type sy-datum.

at selection-screen on p_date.
if p_date+6(2) NE '01' or p_date LE sy-datum.
  message ' error in date' type 'E'.
endif.

Edited by: soumya prakash mishra on Jun 16, 2009 3:22 PM

Read only

0 Likes
907

hi....solved myself.

thanks for your replies.