2009 Feb 16 6:52 AM
Hi Guys,
I have a string = 8425-67123
I need to put a validation which says " enter only digits " if anything other than a digit is entered.
How do i check if anything other than a digit is entered ( in the above case " - " should not be allowed ).
Thanks and regards,
Frank
2009 Feb 16 6:54 AM
2009 Feb 16 6:54 AM
consider this eg:
v_var = 8425-67123
if v_var CO '0123456789'.
write:success.
else.
write:/ error message.
endif.
2009 Feb 16 6:55 AM
hi,
Use
if str1 CO '0123456789'.
process
else.
message.
exit
endif
if str1 CN '0123456789'.
message.
exit
else.
process
endif
if str1 CA sy-abcde.
message.
exit
else.
process
endifUse any of the above three conditions to achieve your purpose. It would resolve.
Thanks and regards
Sharath
2009 Feb 16 6:55 AM
Try this
if string CA sy-abcde.
<<<<<<<<<error message>>>>>>>>>>>
endif.
2009 Feb 16 6:55 AM
Hi,
Try this
declare a constant like this
DATA: c_string(59) TYPE c VALUE
'ABCDEFGHIJKLMNÑOPQRSTUVWXYZ!"#$%&/()=?¡*¨][_:;^`~|°¬ÁÉÍÓÚ´'.
Now check check whether the entered value has any of thiese.
if g_var ca c_string.
message 'Enter only digits' type 'E'.
endif.
Regards,
Venkatesh
2009 Feb 16 6:57 AM
Hi Frank
{code]
IF string CO '0123456789'.
ELSE.
*display error
ENDIF.
{code}
Pushpraj
2009 Feb 16 6:58 AM
Hi Guys,
I have a string = 8425-67123
I need to put a validation which says " enter only digits " if anything other than a digit is entered.
How do i check if anything other than a digit is entered ( in the above case " - " should not be allowed ).
Thanks and regards,
Frank
Hi ,
Use Function Module NUMERIC_CHECK.
call function 'NUMERIC_CHECK'
exporting
string_in = lv_str
importing
htype = lv_type
.
NUMC or NOT
if lv_type eq 'NUMC'.
clear p_del.
else.
p_del = 'X'.
endif.
Edited by: Hüseyin Dereli on Feb 16, 2009 8:59 AM
Edited by: Hüseyin Dereli on Feb 16, 2009 9:00 AM
2009 Feb 16 7:00 AM
2009 Feb 16 7:07 AM
You can use this FM for your requirement,
CALL FUNCTION NUMERIC_CHECK.
Regards,
Joan
2009 Feb 16 8:52 AM
eg:
data : v_va type string .
v_var = 8425-67123
if v_var CO '0123456789'.
logic......
else.
endif.
Regards
2009 Feb 16 8:56 AM
Hi,
Do like this...
parameters:
p_num(6) type n.
data
DATA:
w_str(36) TYPE c VALUE '0123456789'.
IF p_num CO w_str
MESSAGE 'Only Numbers Allowed in this Fields'(009) TYPE 'S'.
endif.
Regards
Kiran
2009 Feb 16 9:49 AM
Hi
You can use any one condition
If string CO '0123456789' .
message 'SUCCESS' type 'S'.
endif.
if string CA sy-abcde.
message 'ERROR' type 'E'.
endif.
Regards,
Rajani
2009 Feb 16 9:59 AM
Hi Frank,
this may help.....
if str CO '1234567890'.
PROCEED.....
else.
MESSAGE 'invalid input' type 'E'.
endif.
Regards,
Mdi.Deeba
2009 Feb 16 10:02 AM
hi!
try this,
DATA: w_str(72) TYPE C Value
'ABCDEFGHIJKLMNÑOPQRSTUVWXYZ!"#$%&/()=?¡*¨][_:;^`~|°~*%$#@(){}[]<>,.?/_-'.
if w_no ca w_str.
message 'Error' type 'E'.
else.
---------------------------(processing of ur code)
endif.