‎2009 May 25 3:47 PM
Hi all,
i have a selection screen for Name.
select-options: s_name for kna1-name1.
i want to do validations for the name, like...
actually the name in the Database contains combination of numbers and characters. (123reyon, etc)
if i ener only the numbers and it should give a error message ' Please enter a valid name'.
how to do this .
Vimala.
‎2009 May 25 3:55 PM
Hi
It's not easy because the S_NAME is a range (select-options) so it can be several combinations, u can try to use something like this:
IF S_NAME-LOW CO (0123456789).
----> message
ENDIF.but u need to checj the field S_NAME-HIGH too
Max
‎2009 May 25 3:53 PM
Hi KR,
Use CO (ContainsOnly) string operation.
Check the below code which may helps you.
IF S_NAME CO '0123456789'.
MESSAGE E001(ZMSG) 'Please enter a valid name'.
ENDIF.
Thanks,
Vinay
‎2009 May 25 3:53 PM
HI,
KNA1-NAME1 is the char field and it can take either number's or Alphbets.
why do you want to validate the name field ?
‎2009 May 25 3:55 PM
Hi
It's not easy because the S_NAME is a range (select-options) so it can be several combinations, u can try to use something like this:
IF S_NAME-LOW CO (0123456789).
----> message
ENDIF.but u need to checj the field S_NAME-HIGH too
Max
‎2009 May 26 7:09 AM
HI all,
i have written some thing like this. but its not giving me error message when i am trying to enter any numbers.
TABLES: kna1.
SELECT-OPTIONS: s_name for kna1-name1.
AT SELECTION-SCREEN .
if s_name-low co '0123456789'.
if sy-subrc = 0.
MESSAGE e001(00) with 'Enter valid name'.
ENDIF.
ELSEIF s_name-HIGH co '0123456789'.
if sy-subrc = 0.
MESSAGE e001(00) with 'Enter valid name'.
ENDIF.
ENDIF.
‎2009 May 26 7:12 AM
No need to check SY-Subrc inside the IF ....CO.
Edited by: Micky Oestreich on May 26, 2009 8:13 AM
‎2009 May 26 7:14 AM
‎2009 May 26 7:17 AM
Hi all,
thanks for response.
now my code looks like this, but still i am unable to give Error message.
TABLES: kna1.
SELECT-OPTIONS: s_name for kna1-name1.
AT SELECTION-SCREEN .
if s_name-low co '0123456789'.
MESSAGE e001(00) with 'Enter valid name'.
ELSEIF s_name-HIGH co '0123456789'.
MESSAGE e001(00) with 'Enter valid name'.
ENDIF.
‎2009 May 26 7:18 AM
Hi.,
It will works in you rcase,
TABLES: kna1.
SELECT-OPTIONS: s_name for kna1-name1.
AT SELECTION-SCREEN .
if not s_name-low ca 'QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm'.
if sy-subrc = 0.
MESSAGE e001(00) with 'Enter valid name'.
ENDIF.
ELSEIF not s_name-HIGH ca 'QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm'.
if sy-subrc = 0.
MESSAGE e001(00) with 'Enter valid name'.
ENDIF.
ENDIF.Thanks,
Naveen.I
‎2009 May 26 7:21 AM
'0123456789 ' (After the '9', enter at least one space).
Add the space character to it.
The name on the screen does not only hold the digits, but there are several 'spaces' in it as well. So NAME does not ONLY contain digits, but spaces as well.
Edited by: Micky Oestreich on May 26, 2009 8:22 AM
Edited by: Micky Oestreich on May 26, 2009 8:23 AM
‎2009 May 26 7:24 AM
TABLES: kna1. " avoid using tables statement . its obsolete
SELECT-OPTIONS: s_name for kna1-name1.
AT SELECTION-SCREEN .
if not s_name-low ca 'QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm'.
MESSAGE e001(00) with 'Enter valid name'.
ELSEIF not s_name-HIGH ca 'QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm'.
MESSAGE e001(00) with 'Enter valid name'.
ENDIF.but still it will work only for one line.
u need to loop if u want for all lines of the select option
‎2009 May 26 7:27 AM
Soumya,
but still it will work only for one line.
u need to loop if u want for all lines of the select option
that's my thought as well, but the way you are suggesting, it would be better to use a regular expression. Then there is no need to enter all the characters UPPER and lower case.
‎2009 May 26 7:28 AM
change it to :
if s_name-low co
*'0123456789 '*.
TABLES: kna1.
SELECT-OPTIONS: s_name for kna1-name1.
AT SELECTION-SCREEN .
condense: s_name-low , condense s_name-high.
if s_name-low co '0123456789 '.
MESSAGE e001(00) with 'Enter valid name'.
ELSEIF s_name-HIGH co '0123456789 '.
MESSAGE e001(00) with 'Enter valid name'.
ENDIF.
Edited by: madhuri sonawane on May 26, 2009 11:59 AM
Edited by: madhuri sonawane on May 26, 2009 12:00 PM
Edited by: madhuri sonawane on May 26, 2009 12:00 PM
‎2009 May 26 7:32 AM
yes i just copies the above code to show the difference..
u can very well use the regular expressions.
‎2009 May 26 7:36 AM
Hi all,
thanks for your response.
Thing is, in my Database some name are like combination of numbers and characters and some names are oonly characters..
example: 28th Medical Colony, 121st Combat Support Hospital ( Name , combination of numbers and characters)
Raja Ram (name, combination of characters only.).
i want to do avalidatin, like, if user enters only numbers, then it should through a Error message.
*************************************************************
the below code is working, if enter only numbers, say 1132424, then i am getting error message,
if i enter 28th Medical Colony, then also i am getting the error message, which coulnnot be happen in my case.
SELECT-OPTIONS: s_name for kna1-name1.
AT SELECTION-SCREEN .
if s_name-low co '0123456789 '.
if sy-subrc = 0.
MESSAGE e001(00) with 'Enter valid name'.
ENDIF.
ELSEIF s_name-HIGH co '0123456789 '.
if sy-subrc = 0.
MESSAGE e001(00) with 'Enter valid name'.
ENDIF.
ENDIF.
***************************************************************
Thanks
‎2009 May 26 7:38 AM
please check the previous page. we have already provided u the solution
‎2009 May 26 7:39 AM
Hi,
This is working fine,
tables: kna1.
select-options: s_name for kna1-name1.
at selection-screen .
if s_name-low is not initial.
if not s_name-low ca 'QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm'.
message e001(00) with 'Enter valid name'.
endif.
endif.
if s_name-high is not initial.
if not s_name-high ca 'QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm'.
message e001(00) with 'Enter valid name'.
endif.
endif.RESULT: This will not allow user to give only NUMBER, He can enter either only Characters or characters with Numbers.
Thanks,
Naveen Inuganti.
‎2009 May 26 7:43 AM
Why not you write a select to check whether the entered name is in database or not and issue a error message ????
Regards
Karthik D
‎2009 May 26 7:45 AM
‎2009 May 26 7:58 AM
Hi Navven,
Thank you very much. its working.
Thing is its a select-options. so, we can give range of names, and what ever the names are there in data base that only fetched. right.
if, they entering a single value , not the range say only from value,
if they enter only numbers, then they need a Error message.
Thank you veru much all of you .
points hasbeen awarded.
‎2009 May 26 7:23 AM
Hi,
try this.
AT SELECTION-SCREEN .
IF s_name-low NA 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
MESSAGE e001(00) WITH 'Enter valid name'.
ENDIF.
ELSEIF s_name-high CA 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
MESSAGE e001(00) WITH 'Enter valid name'.
ENDIF.Regards
Vishnu Gupta
‎2009 May 26 7:29 AM
Hi,
Below is the code. Can you try this?
TABLES: kna1.
SELECT-OPTIONS: s_name for kna1-name1.
AT SELECTION-SCREEN .
if s_name-low co '0123456789 '.
MESSAGE e001(00) with 'Enter valid name'.
ELSEIF s_name-HIGH co '0123456789 '.
MESSAGE e001(00) with 'Enter valid name'.
ENDIF.
I hope you wont get error.
Regards,
Jayanth G
‎2009 May 26 7:38 AM
I guess you will have to do the above logic within a LOOP AT so_fielname (selection option). ENDLOOP.
As Selection option works as an internal table, it will have many records and you might have to validate the whiole stuff.. Else only yeh first low and high of the current values will be validated. Correct me if I am wrong.
Regards,
S.Dakshna Nagaratnam.