2008 May 13 12:39 PM
Hi experts,
I need to validate that a string enetered as parameter is composed of the following character set :
26 alphabets (both in capital or lower case), a (like OBrien), a blank between characters like (Mc Donald). So the total valid characters on any of these fields will be 54.
could You provide with an efficient code ?
Plz Help....
rewards gauranteed........
2008 May 13 12:45 PM
2008 May 13 12:45 PM
2008 May 13 1:07 PM
Hi,
Please find the folowing code.
Use the comparing operator 'CO'. On right side you can write all your 54 possible characters.
data : str1 type string value 'eCA d'.
if str1 Co 'ABCdefghijklmnopqrstuvwx yz*'.
break-point.
endif.
reward if it helps.
regards,
mahantesh
2008 May 13 1:09 PM
Hi,
Check the below code.
data: var(52) type c Value 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.
data: v1(14) type c value 'welcome to SDN'.
data: v2 type i.
data: v3 type i.
v3 = 0.
v2 = STRLEN( v1 ).
do v2 times.
if v1+v3(1) = space .
write:/ 'test contains character space'.
elseif v1+v3(1) ca var.
write:/ 'test'.
elseif v1(v3) = '/'.
write:/ 'test contains character /'.
endif.
v3 = v3 + 1.
enddo.
Regards,
Shravan G.
2008 May 13 2:02 PM
Hello,
You can use regular expressions for validating the characters.
For example:
DATA: lv_string TYPE string VALUE 'My Name is O''Neill'.
DATA: lv_pattern TYPE string VALUE '[a-zA-Z| |'']+'.
DATA: lv_result TYPE boolean.
lv_result = CL_ABAP_MATCHER=>MATCHES( pattern = lv_pattern text = lv_string ).
If lv_result is X, it is OK. If is empty, then a invalid character is in the string.
Regards.