‎2008 Aug 21 4:54 AM
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
‎2008 Aug 21 5:17 AM
data: string(40),
string1(40).
string = 'PACIFIC STAR (HOTEL)'.
split string at '(' into string string1.
write:/ string.
‎2008 Aug 21 4:56 AM
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
‎2008 Aug 21 5:01 AM
Hi ,
Try this,
wf_field = 'PACIFIC STAR (HOTEL)' .
REPLACE '(' WITH space INTO wf_field .
Regards,
Sachin M M
‎2008 Aug 21 5:07 AM
‎2008 Aug 21 5:12 AM
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
‎2008 Aug 21 5:17 AM
data: string(40),
string1(40).
string = 'PACIFIC STAR (HOTEL)'.
split string at '(' into string string1.
write:/ string.
‎2008 Aug 21 5:17 AM
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
‎2008 Aug 21 5:36 AM
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
‎2008 Aug 21 5:51 AM
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