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 a char?

Former Member
0 Likes
955

Hi experts ... my problem is this:

Input: L'Belstar

Output: L Belstar

How I can replace this char?? ... thanks for your help and sry for my bad english =P

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
905

Hello,


DATA:
  lv_test TYPE c LENGTH 10 VALUE 'L''BELSTAR'.

REPLACE ALL OCCURRENCES OF '''' IN lv_test WITH space.

OR


DATA:
  lv_test TYPE c LENGTH 10 VALUE 'L''BELSTAR'.

TRANSLATE lv_test USING ''' '.

Regards.

Hi experts ... my problem is this:

Input: L'Belstar

Output: L Belstar

How I can replace this char?? ... thanks for your help and sry for my bad english =P

7 REPLIES 7
Read only

Former Member
0 Likes
906

Hello,


DATA:
  lv_test TYPE c LENGTH 10 VALUE 'L''BELSTAR'.

REPLACE ALL OCCURRENCES OF '''' IN lv_test WITH space.

OR


DATA:
  lv_test TYPE c LENGTH 10 VALUE 'L''BELSTAR'.

TRANSLATE lv_test USING ''' '.

Regards.

Read only

0 Likes
905

Hi David for your help but i before tried this, when I put this code, the program trigger this error:

"Literals that take up more than one line not permitted"

I need more help ='(

Read only

0 Likes
905

i guess that will be a warning check the color it should be yellow , go ahead activate

Read only

0 Likes
905

Hello,

You need one quote to open the literal, two to represent the quote character and one more to close the literal:


DATA:
  lv_test TYPE c LENGTH 10 VALUE 'L''BELSTAR'.

REPLACE ALL OCCURRENCES OF '''' IN lv_test WITH ' ' IN CHARACTER MODE.

or


DATA:
  lv_test TYPE c LENGTH 10 VALUE 'L''BELSTAR'.

TRANSLATE LV_TEST USING ''' '.

Regards.

Read only

0 Likes
905

Thanks my problem is working with TRANSLATE sentence ... thanks 😃

Read only

0 Likes
905

Hello,

You need to convert the variable to be translated to a type c (just create a variable with type c and the move the contents to this one) and then use one of the commands.

Remember that the length of the c variable must be sufficient to take all characters from the variable to be changed.

Regards.

Read only

Former Member
0 Likes
905

Hi,

Try this code:

data: l_text type string.

data: l_char type c value `'`.

l_text = `L'Belstar`.

replace ALL OCCURRENCES OF l_char

IN l_text WITH ' ' IN CHARACTER MODE.

write: l_text.

Regards,

Joy.