10-23-2007 8:51 AM
Hii All
I have a field value which comes dynamically..this field needs to be checked if it contains other characters other than all A-Z, 0-9, &, #, ', ". If YES, an error message is to be throen..How to do the comparison..pls help
Scond thing is I need to check if this field value has two spaces between two words..if yes, again error..
Tx
10-23-2007 8:53 AM
data: str(100) type c.
data: str_n type string.
data: str_c type string.
data: len type i.
data: ofst type i.
str = '#ABCD%'.
len = strlen( str ).
do.
if ofst = len.
exit.
endif.
if str+ofst(1) co sy-abcde.
concatenate str_c str+ofst(1) into str_c.
else.
concatenate str_n str+ofst(1) into str_n.
endif.
ofst = ofst + 1.
enddo.
write:/ str.
write:/ str_c.
write:/ 'spacial chracter',20 str_n.
Function module SF_SPECIALCHAR_DELETE DX_SEARCH_STRING
l_address1 = i_adrc-street.
CHECK NOT L_ADDRESS1 IS INITIAL.
len = STRLEN( l_address1 ).
do len times.
if not l_address1+l(1) ca
'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 '.
if i_adrc-street+l(1) CO sy-abcde.
elseif i_adrc-street+l(1) CO L_NUMCHAR.
exit.
endif.
l = l + 1.
enddo.
data : spchar(40) type c value '~!@#$$%^&()?...'etc.
data :gv_char .
data:inp(20) type c.
take the string length .
len = strlen (i/p).
do len times
MOVE FNAME+T(1) TO GV_CHAR.
IF gv_char CA spchar.
MOVE fnameT(1) TO inp2T(1).
ENDIF.
T = T + 1.
enddo.
REPORT ZEX4 .
PARAMETERS: fname LIKE rlgrap-filename .
DATA: len TYPE i,
T TYPE I VALUE 0,
inp(20) TYPE C,
inp1(20) type c,
inp2(20) type c,
inp3(20) type c.
DATA :gv_char.
data : spchar(20) type c value '#$%^&*()_+`~'.
START-OF-SELECTION.
CONDENSE fname.
len = strlen( fname ).
WRITE:/ len.
DO len TIMES.
MOVE FNAME+T(1) TO GV_CHAR.
IF gv_char ca spchar.
MOVE fnameT(1) TO inpT(1).
ENDIF.
T = T + 1.
ENDDO.
CONDENSE INP.
write:/ 'Special Characters :', inp.
Rewards if useful..........
Minal Nampalliwar
10-23-2007 9:24 AM
Hi shakir,
data: lv_allowed type string.
concatenate sy-abcde(26) '0123456789&# '''"' into lv_allowed.
if <your test string> NA lv_allowed.
message E0000 'error' .
endif.
Regards,
Clemens