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

Search for SPACE

Former Member
0 Likes
848

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
764

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.

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

4 REPLIES 4
Read only

Former Member
0 Likes
764

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

Read only

Former Member
0 Likes
765

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.

Read only

Former Member
0 Likes
764

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.

Read only

Tamas_Hoznek
Product and Topic Expert
Product and Topic Expert
0 Likes
764

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.