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

Problem with REPLACE ALL OCCURANCES OF

Former Member
0 Likes
2,926

Hi All,

I wanted to replace '#' in my string.

So I have written "REPLACE ALL OCCURRENCES OF '#' IN

c_data WITH ' ".

For some of the records, # is getting replaced but for some of the records # is not getting replaced.

Could you please help me on this.

Edited by: 001krishna on Sep 27, 2011 3:40 AM

4 REPLIES 4
Read only

former_member585060
Active Contributor
0 Likes
2,324

Hi,

Try with TRANSLATE statement. Just click on F1 on the translate statement.

TRANSLATE c_data USING '#'''.  " are you replacing # with single quote(')?

Thanks & Regards

Bala Krishna

Read only

former_member907073
Participant
0 Likes
2,324

Hi,

Try Using REPLACE ALL OCCURRENCES OF REGEX '#*' IN c_data WITH '' '

OR

REPLACE ALL OCCURRENCES OF Substring '#*' IN c_data WITH '' '.

This shud help.

Regds,

AS

Edited by: abheesawant on Sep 27, 2011 6:26 AM

Read only

Clemenss
Active Contributor
2,324

Hi krishna,

please note that SAP will show # for every character that can not be printed, i.e. control characters as tabs and line feeds are displayed as #.

Check in debugger, switch to hex display to see what you try to replace. You may replace CL_ABAP_CHAR_UTILITIES=>horizontal_tab or other attributes of CL_ABAP_CHAR_UTILITIES.

Regards

Clemens

Read only

JackGraus
Active Contributor
0 Likes
2,324

Hi Kishna, the REPLACE command will only replace 'real' characters with ASCII code '23'. Next to these 'real' charecters there might be some non diplayable characters in c_data whose ASCII code is not displayable. These will also be displyed as #. You can check it in the debugger by changing to hex mode. What is the ASCII code of the # characters that are not getting replaced ?

Regards Jack