Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

To find any special character in a string using function module

Former Member
0 Likes
9,529

Hi all,

Is there any function module to find out any special character in a STRING? OR any other method to find a special character???????

points will be rewarded

thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
4,739

Hi,

FCT... i don't know.

you can create a constant contains all special symbol and you can control if string contains one of symbol.

8 REPLIES 8
Read only

Former Member
0 Likes
4,740

Hi,

FCT... i don't know.

you can create a constant contains all special symbol and you can control if string contains one of symbol.

Read only

amit_khare
Active Contributor
0 Likes
4,739

Hi,

Try this FM.

DX_SEARCH_STRING

Regards,

Amit

Read only

0 Likes
4,739
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.

Read only

Former Member
0 Likes
4,739

HI

good

i dont think the function module can help you to find out any special character in a string, for that you have to write the logic,

try this

get the length of the string,

check each and every character using loop and store in a new character variable .

thanks

mrutyun^

Read only

Former Member
0 Likes
4,739

Hi,

store all special characters in internal table

loop at itab.

if string ca itab-char.

write 'special characters'.

endif.

endloop.

Regards

amole

Read only

Former Member
0 Likes
4,739

hi jaysree ,

we have answered this query in one of ur posts ..

in that code just include all the special charaters in to a single string and compare .

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.

regards,

Vijay

Read only

Former Member
0 Likes
4,739

U can check this ..

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.

Read only

Former Member
0 Likes
4,739

Hi,

You can use SEARCH statement

SEARCH dobj FOR pattern

This statement searches the data object dobj according to the search pattern specified in pattern.