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

searching spaces in a string

Former Member
0 Likes
1,485

Hi experts,

how can we search for a space in a string.

the following code is giving sy-subrc = 4 and sy-fdpos = 0 even after i'm having spaces between the strings.

DATA: STR(25) TYPE C VALUE 'welcome abc ghj',

SEARCH STR FOR ' '.

WRITE:/ SY-SUBRC.

WRITE:/ SY-FDPOS.

can anybody tell me how to do it

Rgds,

Prajith

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,178

hI..

IF STR CA SPACE.

*WRITE:/ SY-SUBRC.

WRITE:/ SY-FDPOS.

ENDIF.

Hi experts,

how can we search for a space in a string.

the following code is giving sy-subrc = 4 and sy-fdpos = 0 even after i'm having spaces between the strings.

DATA: STR(25) TYPE C VALUE 'welcome abc ghj',

SEARCH STR FOR ' '.

WRITE:/ SY-SUBRC.

WRITE:/ SY-FDPOS.

can anybody tell me how to do it

Rgds,

Prajith

4 REPLIES 4
Read only

Former Member
0 Likes
1,179

hI..

IF STR CA SPACE.

*WRITE:/ SY-SUBRC.

WRITE:/ SY-FDPOS.

ENDIF.

Read only

Former Member
0 Likes
1,178

Hi,

DATA: STR(25) TYPE C VALUE 'welcome abc ghj',

SEARCH STR FOR SPACE.
WRITE:/ SY-SUBRC.
WRITE:/ SY-FDPOS.

Regards

Sudheer

Read only

Former Member
0 Likes
1,178

HI,

CHANGE ' ' TO ` `.

TRY THIS CODE.

DATA: STR(25) TYPE C VALUE 'welcome abc ghj',

SEARCH STR FOR <b><b>` `</b>.</b>

WRITE:/ SY-SUBRC.

WRITE:/ SY-FDPOS.

REGARDS,

ANANTH

Message was edited by:

ananth

Read only

Former Member
0 Likes
1,178

hi prajith

<u><i><b>first method</b></i></u>

SEARCH STRING FOR SPACE.

Here STRING would be your String, if this find the Space in your string then the SY-FDPOS will be the position number in the string, if there is no spacve, then the SY-FDPOS will be blank

<u><i><b>second method</b></i></u>

DATA : TEXT(15) TYPE C VALUE '12345 789'.

DATA : NUM1(15),NUM2(15).

SPLIT TEXT AT SPACE INTO NUM1 NUM2.

IF NOT NUM2 IS INITIAL.

WRITE : / 'TEXT CONTAINS STRING'.

ENDIF.

regards

navjot

reward all helpfull answers