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

String

Former Member
0 Likes
961

Dear Friends,

Please help me to resolve the below issue.

Let us assume the following

DATA: source TYPE string,

source = 'This is a /entlittle /ent* sentence.'.

I just wanted to find /ent* in the above string

The function "search" is used for the purpose.

But the problem here is, "the * in the above string is

considered as a wildcard character & not a character".

So the result of sy-subrc after search is 4.

Could anyone resolve this issue.

Regards,

Usha

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
890

You can try this

DATA : source(50).

source = 'This is a /entlittle /ent* sentence.'.

IF source CS '/ent*'.

WRITE: sy-fdpos.

ENDIF.

sy-fdpos = sy-fdpos + 1.

WRITE:/ source+sy-fdpos(4).

Regards,

Prabhu Rajesh.

8 REPLIES 8
Read only

jayanthi_jayaraman
Active Contributor
0 Likes
890

Hi,

If that is the case,then try this.

DATA: source TYPE string,

s_one type string,

s_two type string.

source = 'This is a /entlittle /ent* sentence.'.

SPLIT source AT '/ent*' INTO s_ONE s_TWO.

if sy-subrc eq 0.

Here you can understand that the string is containing '/ent' without using search

write s_two.

endif.

Read only

andreas_mann3
Active Contributor
0 Likes
890

hi usha,

try that:

IF source CS '/ent*'.
  found = 'X'.
ENDIF.

regards Andreas

Read only

0 Likes
890

Don't forget the SY-FDPOS to know the offset when the CS had result.

Read only

Former Member
0 Likes
890

Jayanthi,

I am using the position of search string in the other part of the code, so split doesn't help in this case.

Regards,

Usha

Read only

0 Likes
890

Hi Usha,

If you need the position, you can use the solution provided by Jayanthi and then something like this :


w_position = strlen( s_ONE ).

Hope this helps,

erwan.

Read only

0 Likes
890

Hi,

As Erwan told you can use strlen .

DATA: source TYPE string,

s_one type string,

s_two type string,

n type i.

source = 'This is a /entlittle /ent* sentence.'.

SPLIT source AT '/ent*' INTO s_ONE s_TWO.

if sy-subrc eq 0.

<b>n = strlen( s_one ).

write n.</b>

endif.

If it doesn't suit your requirement,tell the exact thing you want to achieve from search.

Give your coding part also.

Read only

Former Member
0 Likes
891

You can try this

DATA : source(50).

source = 'This is a /entlittle /ent* sentence.'.

IF source CS '/ent*'.

WRITE: sy-fdpos.

ENDIF.

sy-fdpos = sy-fdpos + 1.

WRITE:/ source+sy-fdpos(4).

Regards,

Prabhu Rajesh.

Read only

Former Member
0 Likes
890

Prabhu / Andreas,

Thanks. The problem is resolved.

Regards,

Usha