Application Development 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: 

Issue with replacing carriage return in a string

Former Member
0 Kudos

I need to do the following:

d_tab = cl_abap_char_utilities=>horizontal_tab.
  d_line = cl_abap_char_utilities=>cr_lf.

replace ',' in d_contract with ' '.
    replace d_tab in d_contract with ' '.
    replace d_line in d_contract with ' '.
condense d_contract.

but it isn't working. It is replacing the horizontal tab but it is not replacing the carriage return. When I look in the debugger the field d_contract is '###'. After it replaces d_tab I have d_contract = '##'. It is my understanding that a carriage return is represented as ##. Also, this is the last field in the line so I assume it is a carriage return.

When it tries to replace d_line in d_contract (carriage return in the field) it doesn't replace anything.

Any ideas?

Regards,

Davis

3 REPLIES 3

Former Member
0 Kudos

The problem ended up being extra tabs. I fixed the issue by changing the delete statements to delete all and I also added an extra field in the split statement.

0 Kudos

>

> The problem ended up being extra tabs. I fixed the issue by changing the delete statements to delete all and I also added an extra field in the split statement.

Can you or anyone explain more of this? Thank you so much..i got the same problem...

0 Kudos

I did the following:

d_tab = cl_abap_char_utilities=>horizontal_tab.

replace all occurrences of ',' in d_contract with ' '.

replace all occurrences of d_tab in d_contract with ' '.

condense d_contract.

The split is as follows(the variables aren't the same but I don't have the code in front of me): split wa_string at d_var d_var1 d_var2 d_Var3 d_contract d_string.

I added the variable d_string to the split. This will consume all extra characters in the string (this is where the extra tabs will go).

Regards,

Davis