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

Problem with SEARCH statement in the program

Former Member
0 Likes
577

I have below program:

DATA: V_1(03) TYPE C,

V_2 TYPE STRING.

V_1 = '9.0'.

SEARCH V_1 FOR '.' .

IF SY-SUBRC EQ 0.

REPLACE '.' IN V_1 WITH ' '.

ENDIF.

but search statement is not working,it sy-subrc eq 4.

Can anybody tell me why it is like this ?

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
546

Easy solution.....




DATA: V_1(03) TYPE C,
V_2 TYPE STRING.

V_1 = '9.0'.

TRANSLATE V_1 using '. '.

Regards,

Rich Heilman

3 REPLIES 3
Read only

Former Member
0 Likes
546

hi,

do this way...


DATA: V_1(03) TYPE C,
V_2 TYPE STRING.

V_1 = '9.0'.

REPLACE '.' IN V_1 WITH ' '.

Regards,

Santosh

Read only

Former Member
0 Likes
546

From F1 on SEARCH:

The statement SEARCH has been replaced with the statement FIND in Release 6.10.

The search patterns 'str' and '.str.' are identical apart from a few exceptions. You must

use '.str.' when the pattern str contains spaces (at the end), the '.' character (at the

beginning and end), or the '*' character (at the end). You should also use '.str.' when the

search string str is variable and you cannot predict when you write the statement what the

contents of the string will be.

This should work:

DATA: v_1(03) TYPE c,
v_2 TYPE string.

v_1 = '9.0'.

SEARCH v_1 FOR '...' .         <====

IF sy-subrc EQ 0.

  REPLACE '.' IN v_1 WITH ' '.

ENDI

But it will compress the space.

Rob

Edited by: Rob Burbank on Feb 22, 2008 1:48 PM

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
547

Easy solution.....




DATA: V_1(03) TYPE C,
V_2 TYPE STRING.

V_1 = '9.0'.

TRANSLATE V_1 using '. '.

Regards,

Rich Heilman