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

Find and replace with space

Former Member
0 Likes
883

Hello ABAPers,

I need to find the '(' starting on that need to replace it with space until the end of the string.

for example : PACIFIC STAR (HOTEL) , so from '(' omit it , also the hotel word and the last ')'.

How can i do that?

Please help.

Thanks in advance

aVaDuDz

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
846

data: string(40),

string1(40).

string = 'PACIFIC STAR (HOTEL)'.

split string at '(' into string string1.

write:/ string.

8 REPLIES 8
Read only

Former Member
0 Likes
846

Use:


REPLACE ALL OCCURENCES OF

OR


TRANSLATE

Search the forum for examples.

Oops. Ignore above answer. Didnt get your question right.

If it is always at the end of the string you can do something like this:


FIND '(' IN string.

This will give you the position of the the ( in sy-fdpos. then you can use offsets to just get you required string +0(sy-fdpos)

Edited by: Aparna Shekhar on Aug 20, 2008 11:05 PM

Read only

sachin_mathapati
Contributor
0 Likes
846

Hi ,

Try this,

wf_field = 'PACIFIC STAR (HOTEL)' .

REPLACE '(' WITH space INTO wf_field .

Regards,

Sachin M M

Read only

Former Member
0 Likes
846

Hi,

Use TRANSLATE

Eg: Translate a with '( ' .

Read only

naveen_inuganti2
Active Contributor
0 Likes
846

Hi....

Now it is...

> PACIFIC STAR (HOTEL)

You want to change it as...

> PACIFIC STAR

Am i correct?

So...

You want to replace that in runtime or to modify the code?

Can you plz get once again?

Thanks,

Naveen.I

Read only

Former Member
0 Likes
847

data: string(40),

string1(40).

string = 'PACIFIC STAR (HOTEL)'.

split string at '(' into string string1.

write:/ string.

Read only

Former Member
0 Likes
846

Hi,

for this we can use REPLACE , SPLIT.

DATA: c TYPE string,
      a type string.

c = 'PACIFIC STAR (HOTEL)'.
a = '(HOTEL)'.
REPLACE ALL OCCURRENCES OF a IN c WITH ' '.

write: c.

or.

DATA: l_str1 type string,
      l_str2 type string,
      l_str type string,
      l_replacestr type string.

l_str = 'PACIFIC STAR (HOTEL)'.

l_replacestr = '(HOTEL)'.

split l_str at l_replacestr into l_str1 l_str2.

write: l_str1.

hope this helps.

thanx,

dhanashri.

Edited by: Dhanashri Pawar on Aug 21, 2008 6:32 AM

Read only

naveen_inuganti2
Active Contributor
0 Likes
846

Hi...

You can use SPLIT statement....

Check this smaple query...

data: n(8), m(8).

n = 'Hi N(RT)'.

SPLIT n at '(' into n m.

write:/ n.

which gives output as

> Hi N

Thanks.

Naveen.I

Read only

Former Member
0 Likes
846

Hi I would reccomend use of below syntax.

Data str1 type string

str1 = 'PACIFIC STAR (HOTEL) '.

REPLACE ALL OCCURRENCES OF ')' IN str1 WITH ' '.

OR

REPLACE ALL OCCURRENCES OF ')' IN str1 WITH space.

rgds

rajesh