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 # from string

Former Member
0 Likes
13,727

hello,

I've got the following problem

I receive an xml string with some '#' characters and would like to remove them

I know that replace ... '#' doesn't work because it's not actually the char '#' that should be removed but it's a

hexadecimal character (I think it's a blanc)

any ideas on how to do this ?

regards

1 ACCEPTED SOLUTION
Read only

former_member209217
Active Contributor
0 Likes
5,393

Hi,

Switch to debugging mode .Check this character in debugging mode and try to find wat exactly this character is?

I thnk that the characters which are not interpreted by SAP are shown as #. It means that characters which cannot be printed are

shown as #.

Regards,

Lakshman.

11 REPLIES 11
Read only

former_member209217
Active Contributor
0 Likes
5,394

Hi,

Switch to debugging mode .Check this character in debugging mode and try to find wat exactly this character is?

I thnk that the characters which are not interpreted by SAP are shown as #. It means that characters which cannot be printed are

shown as #.

Regards,

Lakshman.

Read only

0 Likes
5,393
symbol is used for new line carried feed variable. It can be replaced with the following code.( will be used in Long Text to ALV )

REPLACE ALL OCCURRENCES OF CL_ABAP_CHAR_UTILITIES=>NEWLINE IN < your String > WITH SPACE.

Regards.

Nawal

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
5,393

check with replace in byte mode

Read only

former_member459142
Participant
5,393

hiiii

REPLACE ALL OCCURRENCES OF '#' IN your_variable WITH ' '.

It should work.

Thanks & Regards

Prashant Gupta

Read only

Former Member
5,393

Hi,

  1. characters cannot be removed because they are actaully hexadecimal charcters like horizontal tabs etc.

Use the class CL_ABAP_CHAR_UTILITIES and the HORIZONTAL_TAB attribute or other relevant one so that you can remove the #.

Regards,

Subhashini

Read only

Former Member
0 Likes
5,393

Hi,

  1. symbol is used for new line carried feed variable. It can be replaced with the following code.


Replace all occurances of CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB in string with space

or


Replace all occurances of CL_ABAP_CHAR_UTILITIES=>NEWLINE in string with space.

Regards,

Vik

Read only

Former Member
0 Likes
5,393

thanks for your replies

I've used the class CL_ABAP_CHAR_UTILITIES but none of the provided attributes (CR_LF, horizontal_tab, ..) work

I think that's it's a hex blanc that should be removed

Read only

0 Likes
5,393

Hi,

If you can go to the debugger and at the right of the field value we have a hex viewer click on that and see what is the value of the space in HEX then in your code declare a variable as hex and try to replace it as below.

 

data: lv_char type 'X' value '09'.

replace lv_char with space in text.

Regards,

Himanshu

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
5,393

Hello,

I think in debugging you should check the hex value for this #.

This will give you an idea which value you need to replace for the class CL_ABAP_CHAR_UTILITIES viz., NEWLINE(0A), CR_LF(0D0A) etc.

Hope this helps.

BR,

Suhas

Read only

Former Member
0 Likes
5,393

Hello,

I guess you are getting this # as a result of xml transformation.

You can either use shift to shift xml string 1 place to remove '#' char or you can use offset to

replace it with space. For e.g. string+1(1) = space.

Check if this helps,

Thanks,

Augustin.

Read only

Former Member
0 Likes
5,393

thanks for the replies

solved it in another way but if someone knows the answer with hexadecimal formatting ...