‎2006 Nov 14 4:07 AM
Hi All,
We have a project requirement of giving an error message if a string has characters other then the ones valid.
Scenario is :
wf_ex field can have characters from alphabets,digits and underscroe and if t has characters other than the ones specified we hav to give an error message
At present we are finding the length of the variable and
we are looping for the number of times of length of the var and chking out if each char is ther in the allowed set of values.
But there is a performance problem in this .Any suggestion in this regardis highly appreciable.
We need to find out if the varirable has any other charcters other than the one specified.
Its very urgent.
regards,
Rajashree
‎2006 Nov 14 4:20 AM
HI,
One simple way is this
DATA: var type string.
CONSTANTS: const type string value 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_'.
if var CO const.
*This is valid
else.
invalid.
Regards,
Sesh
endif.
‎2006 Nov 14 4:20 AM
HI,
One simple way is this
DATA: var type string.
CONSTANTS: const type string value 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_'.
if var CO const.
*This is valid
else.
invalid.
Regards,
Sesh
endif.
‎2006 Nov 14 6:21 AM
Hi,
We have already doen this but it's not working is ther any other way of doing this.
Regards,
Rajashree
‎2006 Nov 14 6:23 AM
Try this one.
data: str(100) type c.
data: str_n type string.
data: str_c type string.
data: str_d type string.
data: str_p type string.
data: len1 type i.
data: ofst1 type i.
str = '#ABCD%123'.
len1 = strlen( str ).
do.
if ofst1 = len1.
exit.
endif.
if str+ofst1(1) co sy-abcde .
concatenate str_c str+ofst1(1) into str_c.
elseif str+ofst1(1) co '0123456789' .
concatenate str_p str+ofst1(1) into str_p.
else.
concatenate str_d str+ofst1(1) into str_d.
endif.
ofst1 = ofst1 + 1.
enddo.
‎2006 Nov 14 6:31 AM
Hi,
We are using this currently ,we need a way such that it can be done in one shot as loop or do would create performance issues.
Regards,
Rajashree
‎2006 Nov 14 7:42 AM
DATA: var type string.
CONSTANTS: const type string value 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_'.
if var CO const.
*This is valid
else.
invalid.
Modify the above example as follows:
CONSTANTS: const type string value 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_ '.
SPACE is there after '_' and try
otherwise try this.
len = strlen( var ).
if var+0(len) CO const.
*valid
else
*invalid
‎2006 Nov 14 8:19 AM
Hi All,
I have found out the solution .
It wud be enough if we use CN.
Thanks a lot for your suggestions.
‎2006 Nov 14 6:31 AM
Hi Rajashree,
Try With these FM's.
CLHU_FIND_STRING_IN_TABLE
CPWBBROWSER_SEARCH_FOR_STRING
FC_GET_SEARCH_STRING
STRING_FIND_WORD_FUZZY
G_BOOL_TABLE_CHECK_STRING
CHECK_STRING_ALPHA_SUCCESSOR
CHECK_STRING_DIGIT_SUCCESSOR
CHECK_STRING_SUCCESSOR
CHECK_STRING_SPEC_CHARACTERS
SCP_CHECK_CHARSET_OF_STRING
SF_STRING_CHECK
STRING_COMPARE_FUZZY
SWA_STRING_FIND_ALL
SWF_TASKS_OF_SEARCHSTRING_GET
SD_SOURCE_SEARCH_FOR_STRING
POSED_SEARCH_STRING
POSED_SEARCH_STRING_WPUBONRegards,
Raghav