Application Development 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: 

Search for SPACE

Former Member
0 Kudos

hi there.... i want to search for SPACE in a string. Search ' '..... is not working. CAn anyone help.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

data: v_len type i.

IF str CA ' ' .

v_len = sy-fdpos.

ENDIF.

For your example, the above query returns v_len (sy-fdpos) as 4 and the 5th position is space.

4 REPLIES 4

Former Member
0 Kudos

Hi

Check this

:

DATA string7(30) TYPE c VALUE 'This is a little sentence.'.

WRITE: / 'Searched', 'SY-SUBRC', 'SY-FDPOS'.

ULINE /1(26).

SEARCH string7 FOR ' '.

WRITE: / ' ', sy-subrc UNDER 'SY-SUBRC',

sy-fdpos UNDER 'SY-FDPOS'.

Hope it helps.

Praveen

Former Member
0 Kudos

data: v_len type i.

IF str CA ' ' .

v_len = sy-fdpos.

ENDIF.

For your example, the above query returns v_len (sy-fdpos) as 4 and the 5th position is space.

Former Member
0 Kudos

Try this code:

DATA: A(50) TYPE C VALUE 'AMIT GUPTA',

B TYPE C,

N(2) TYPE N.

N = STRLEN( A ).

DO N TIMES VARYING B FROM A0(1) NEXT A1(1) RANGE A.

IF B IS INITIAL.

" DO ANYTHING

ENDIF.

ENDDO.

tamas_hoznek
Product and Topic Expert
Product and Topic Expert
0 Kudos

Actually, the correct syntax to find SPACE is:

SEARCH stringname FOR '. .'.

The strange thing is that the FIND command is not able to find SPACE. At least I tried it in every way I could think of but it didn't work. So I had to use the (otherwise obsolete) SEARCH command with the above syntax.