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

Replace protected spaces in string

Former Member
0 Likes
656

Hi together,

I think I've got a quite easy problem, but no idea how to solve it.

I've got a string for example ' Hello' the spaces are protected ones, represented

in hex as 'A0'.

Using condense to delete the leading spaces has no effect on my string?

Has anyone a hint how to solve this?

King regards

Lars

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
552

Try as below

Data : v_space type c value CL_ABAP_CHAR_UTILITIES=>Horizontal_tab.

REPLACE ALL OCCURRENCES OF  v_space in v_string with ' '.
condense v_string NO-GAPS.

hope this helps...

4 REPLIES 4
Read only

Former Member
0 Likes
552

Hi,

Try it with string operations.

for example:

w_str = 'Hello '.
w_len = strlen( w_str ).
subtract 2 from w_len.
w_str2 = w_str+0(w_len).

Regards,

Manoj Kumar P

Read only

Former Member
0 Likes
553

Try as below

Data : v_space type c value CL_ABAP_CHAR_UTILITIES=>Horizontal_tab.

REPLACE ALL OCCURRENCES OF  v_space in v_string with ' '.
condense v_string NO-GAPS.

hope this helps...

Read only

0 Likes
552

Thanks your both of your ideas,

but CL_ABAP_CHAR_UTILITIES=>Horizontal_tab.

is represented in hex as '09'.

Kind regards

Read only

Former Member
0 Likes
552

Hi together,

I've found a working solution, maybe it's interessting for u.

Data: lv_rep(1) TYPE c.

Data: lv_replace type string.

lv_replace = ' Test'.

CALL METHOD cl_abap_conv_in_ce=>uccp

EXPORTING

uccp = '00A0'

RECEIVING

char = lv_rep.

REPLACE ALL OCCURRENCES OF lv_rep IN lv_replace WITH ' '.

This works.

Kind regards.

Lars