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

How to replace apostrophe with space

Former Member
0 Likes
3,886

Hi Experts,

I need to replace the Apostrophe in Material description with space. I am getting a error as the text literal .....longer than 255.

highly appreciated for immediate response.

REPLACE ALL OCCURRENCES OF ''' IN WA_MAKTX WITH ''.

thanks,

RRR

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,350

Hi Rammi,

Try like this.

REPLACE ALL OCCURRENCES OF ''' IN WA_MAKTX WITH SPACE.

Hi Experts,

I need to replace the Apostrophe in Material description with space. I am getting a error as the text literal .....longer than 255.

highly appreciated for immediate response.

REPLACE ALL OCCURRENCES OF ''' IN WA_MAKTX WITH ''.

thanks,

RRR

10 REPLIES 10
Read only

Former Member
0 Likes
2,351

Hi Rammi,

Try like this.

REPLACE ALL OCCURRENCES OF ''' IN WA_MAKTX WITH SPACE.

Read only

0 Likes
2,350

Hi Pravin,

The problem is not with Space it is coz of the single quotes open quote '''. This is causing the problem how to overcome this.

REPLACE ALL OCCURRENCES OF ''' IN WA_MAKTX WITH SPACE.

Thanks,

rrr

Read only

0 Likes
2,350

So you simply use doubled apostrophes as to suppress its special meaning


data: str_var type string VALUE 'some text with '' and another '' '.

write: 'Before:' , str_var.

replace all OCCURRENCES OF '''' in str_var with ` `.

write: / 'After:', str_var.

Regards

Marcin

Read only

0 Likes
2,350

Hi Pciak,

I have already tried with 2 quotes of '''' syntax is fine but when i debug it is not replacing the apostrophe.

Thanks,

rrr

Read only

0 Likes
2,350

I am just curious if you tried the above? If you debug you would see that str_var contains initially two apostrophes, after the replace statement its not there anymore. I am missing something?

Regards

Marcin

Read only

MarcinPciak
Active Contributor
0 Likes
2,350

REPLACE ALL OCCURRENCES OF ''' IN WA_MAKTX WITH ` `. "use backquotes and space character in b/w

Regards

Marcin

Read only

Former Member
0 Likes
2,350

Hi,

What MARCIN had suggested will work.

Still problem persists create a text element with the value of apostrophe ie. '

eg text element TEXT-001 = ' " create the text element

REPLACE ALL OCCURRENCES OF TEXT-001 IN <YOUR STRING> WITH SPACE.

Regards,

Smart

Read only

kesavadas_thekkillath
Active Contributor
2,350

Try this


replace all occurrences of `'` in lv_string with ` `.

Read only

Former Member
0 Likes
2,350

Hi Rammi,

Hi have tried with the below code and I am getting the proper output as well.

DATA wa_maktx(10) TYPE c.

wa_maktx = 'as"dfg'.

REPLACE ALL OCCURRENCES OF '"' IN WA_MAKTX WITH SPACE.

write:/2 wa_maktx.

output:

asdfg

Regards,

Md Ziauddin.

Read only

Former Member
0 Likes
2,350

Hi Rammi

You can try in this way

DATA: LV_STRING TYPE STRING.

DATA: REP_STRING TYPE STRING .

REP_STRING = ''''.

LV_STRING = 'some'' text '' have replace '.

DO.

SEARCH LV_STRING FOR REP_STRING.

IF SY-SUBRC = 0.

REPLACE REP_STRING WITH SPACE INTO LV_STRING.

ELSE.

EXIT.

ENDIF.

ENDDO.

Regards,

Nilay