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 Carriage return from string

Former Member
0 Likes
4,873

I have a free text area on a BSP (a form). When users type continuously in this area the text gets wraped. When the BSP is submitted it generates a sapscript form and the text area is printed on the form, but it has '##' which are placed where the text wrapped round. I would like to remove '##', so tried the following:

replace all occurrences of '##' in text_area with ' '.

This did not work as the '##' are not recognised presumably because they are some type of carriage return and not in fact has marks.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,011

You can find the hexadecimal value for a carriage return (0x0d) and then replace that with spaces.

But if replace statement has problems operating on non char like characters. The we have to look for some work around.

The work around can be declaring a constant for the carraige return referring to the CL_ABAP_CHAR_UTILITIES class CR_LF attribute.

CL_ABAP_CHAR_UTILITIES=>CR_LF.

and then use it in replace statement.

4 REPLIES 4
Read only

Former Member
0 Likes
2,012

You can find the hexadecimal value for a carriage return (0x0d) and then replace that with spaces.

But if replace statement has problems operating on non char like characters. The we have to look for some work around.

The work around can be declaring a constant for the carraige return referring to the CL_ABAP_CHAR_UTILITIES class CR_LF attribute.

CL_ABAP_CHAR_UTILITIES=>CR_LF.

and then use it in replace statement.

Read only

raja_thangamani
Active Contributor
0 Likes
2,011

Hi,

Use Method

cl_abap_char_utilities=>cr_lf

Raja T

Read only

Former Member
0 Likes
2,011

Hello,

Check out using this,

cl_abap_char_utilities=>cr_lf

Regards,

Shehryar Dahar

Read only

0 Likes
2,011

If you dont have access to the class CL_ABAP_CHAR_UTILITIES, do this instead:


DATA: crlf(2)   TYPE x VALUE '0D0A',
      itab      TYPE TABLE OF string,
      w_input   TYPE string.

   w_input = '<contains the text with the line feed.>'.

   SPLIT w_input AT crlf INTO TABLE itab.

Regards Michael.