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

remove character from a string

Former Member
0 Likes
1,255

wats the command to remove characters in a string?

I have to remove 'bb' from a string

1 ACCEPTED SOLUTION
Read only

JozsefSzikszai
Active Contributor
0 Likes
1,120

hi,

you can try the REPLACE statement. There will be a space in the string instead of 'bb', which you can delete with CONDENSE ... NO-GAPS.

hope this helps

ec

7 REPLIES 7
Read only

JozsefSzikszai
Active Contributor
0 Likes
1,121

hi,

you can try the REPLACE statement. There will be a space in the string instead of 'bb', which you can delete with CONDENSE ... NO-GAPS.

hope this helps

ec

Read only

0 Likes
1,120

If you are replacing bb by ' ' there will be a gap, but why dont you replace it by ''?

Read only

0 Likes
1,120

just checked:

DATA : text(10) TYPE c VALUE 'AABBCC'.

REPLACE 'BB' IN text WITH ''.

and really text is 'AACC' after the above

(I remembered so that a space was left there, even if the replacing value was 'nothing' and I had to use the CONDENSE ... NO-GAPS afterwards to delete that unnecessary space. There are two options: 1. My memories are wrong 2. It happened in earlier releases (now I tried in 4.7). Anyway, thanks for your correction!)

Read only

0 Likes
1,120

Just said so because the condense may delete gaps which should not be affected...

Nevertheless i cant tell you if this was working different in 4.7. i started to use this command in ERP 2005.

Read only

Former Member
0 Likes
1,120

Hello


DATA FIELD(10).
MOVE 'ABCBB' TO FIELD.
REPLACE 'BB' WITH ' ' INTO field.
CONDENSE field.

Read only

Former Member
0 Likes
1,120

Hi


DATA lv_field(5).
MOVE 'CCCBB' TO lv_field.
SEARCH lv_field FOR 'BB'.
IF sy-subrc = 0.
  REPLACE 'BB' WITH ' ' INTO lv_field.
  CONDENSE lv_field.
  WRITE lv_field.
ENDIF.

Read only

Former Member
0 Likes
1,120

Please do not double-post or cross-post your questions.

We typically delete all the questions when this is found.

Cheers,

Julius