‎2007 May 08 3:35 PM
Hi all,
Is there any simple way or Fm to check the stringcontains other than alphanumeric(A-Z and 0-9) and give an error message.
Thanks
Sukumar
‎2007 May 08 3:45 PM
Hai Sukumar,
Here is the logic.
DATA:
W_ALPHA_NUMERIC(36) TYPE C.
CONCATENATE SY-ABCDE '0123456789' INTO W_ALPHA_NUMERIC.
Suppose you want to check W_VAR wheteher it has other than ALPHA_NUMERIC .
IF W_VAR CO W_ALPHA_NUMERIC.
*"Do your task here
ELSE.
MESSAGE 'Contains Non ALPHA_NUMERIC Values' TYPE 'E'.
ENDIF.
Regdards,
Rama chary.Pammi
‎2007 May 08 3:38 PM
check this which deletes special characters
REPORT ychatest.
DATA : v_char(25) VALUE 'A-B^34567-987',
v_char1 LIKE fist-searchw.
v_char1 = v_char.
CALL FUNCTION 'SF_SPECIALCHAR_DELETE'
EXPORTING
with_specialchar = v_char1
IMPORTING
without_specialchar = v_char1.
v_char = v_char1.
WRITE : v_char.
‎2007 May 08 3:44 PM
Hi chandrasekhar,
Thanks for your reply.
I checked that FM already.But it will not cover some characters like {} etc.
So, I want to check the string which doesnt contain alpha numeric and give them some msg.
thanks
‎2007 May 08 3:45 PM
Hai Sukumar,
Here is the logic.
DATA:
W_ALPHA_NUMERIC(36) TYPE C.
CONCATENATE SY-ABCDE '0123456789' INTO W_ALPHA_NUMERIC.
Suppose you want to check W_VAR wheteher it has other than ALPHA_NUMERIC .
IF W_VAR CO W_ALPHA_NUMERIC.
*"Do your task here
ELSE.
MESSAGE 'Contains Non ALPHA_NUMERIC Values' TYPE 'E'.
ENDIF.
Regdards,
Rama chary.Pammi
‎2007 May 08 3:45 PM
Hi,
Please try this.
data: str type string.
data: valid_characters type string.
concatenate '0123456789' sy-abcde into valid_characters.
str = '123ABC'.
if str co valid_characters.
write: / 'Characters are OK'.
else.
write: / 'Characters are not OK'.
endif.
Regards,
Ferry Lianto
‎2007 May 08 3:46 PM
hi sukumar,
try this code:
data: str type char62 value 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'.
if var1 CO str.
continue.
else.
print error message.
endif.
var1 is ur variable to b checked.
length of str may be 36 if case of alphabet is known beforehand.
plz reward points if helpful.
rgrds,
Avijit