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: 

express CR_LF

Former Member
0 Kudos

What is the right expression for line feed .

Below command is not correctly. How can I express

line feed CR_LF .

REPALCE ALL OCCURENCES OF '#' WITH CR_LF

IN s_test .

I intend to replace

data s_test type string.

s_test = 'afafdfd#retretertre#vmnmnmnmmnbnm#'.

reagrds

sas

1 ACCEPTED SOLUTION

Former Member
0 Kudos

I am using release SAP ECC 6.0.

Yes this class is existing but I dont understand what you mean

exactly.

Pablo to sum up:

I need a way on how to replace # with new line

or line feed.

I have the following command but it returns not the

correctly result.


data s_test type string.
s_test = 'afafdfd#retretertre#vmnmnmnmmnbnm#'.
REPLACE ALL OCCURRENCES OF '#' IN s_test WITH CL_ABAP_CHAR_UTILITIES=>CR_LF.
write: s_test.

result:

afafdfd##retretertre##vmnmnmnmmnbnm##

23 REPLIES 23

former_member188685
Active Contributor
0 Kudos

'#' means may be horizontal tab or New Line.

REPALCE ALL OCCURENCES OF CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB WITH CR_LF 
IN s_test .

REPALCE ALL OCCURENCES OF CL_ABAP_CHAR_UTILITIES=>NEW_LINE WITH CR_LF 
IN s_test .

0 Kudos

Vijay Babu Dudla thank you.

But I get the message-> WITH CR_LF is not expected

at the simple coding below.

REPORT ZTEST19.

data hg type string.
hg = 'afafdfd#retretertre#vmnmnmnmmnbnm#'.


*REPLACE ALL OCCURENCES OF CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB 
*WITH CR_LF IN s_test .
 
REPLACE ALL OCCURENCES OF CL_ABAP_CHAR_UTILITIES=>NEW_LINE WITH CR_LF 
IN s_test .

Former Member
0 Kudos

Try using CL_ABAP_CHAR_UTILITIES=>CR_LF.

data s_test type string.

s_test = 'afafdfd#retretertre#vmnmnmnmmnbnm#'.

REPALCE ALL OCCURENCES OF '#' WITH CL_ABAP_CHAR_UTILITIES=>CR_LF

IN s_test .

Regards,

Joy.

Former Member
0 Kudos

I am sooryy but I get also here the same message

WITH CL_ABAP_CHAR_UTILITIES=>CR_LF

is ot expected

I am using release SAP ECC 6.0

What is wrong

0 Kudos

Hi,

Try this:

data s_test type string.

s_test = 'afafdfd#retretertre#vmnmnmnmmnbnm#'.

REPLACE ALL OCCURRENCES OF '#' IN s_test WITH CL_ABAP_CHAR_UTILITIES=>CR_LF

in character mode.

Regards,

Joy.

0 Kudos

you have to turn the WITH and IN operators around, then it should work.

>REPLACE ... OF ... IN ... WITH ...

Former Member
0 Kudos

Hi freineds

thank you all. The syntax problem is solved

but result is NOT OK.

REPLACE ALL OCCURRENCES OF '#' IN s_test WITH CL_ABAP_CHAR_UTILITIES=>CR_LF.

write: s_test.

result:

afafdfd##retretertre##vmnmnmnmmnbnm##

0 Kudos

Hi,

have you declared the class thus?


*----------------------------------------------------------------------*
* Classes                                                              *
*----------------------------------------------------------------------*

* direct definition of CR, LF etc. Alternatively use HLP_CR, HLP_LF etc.
* to fill the separators in payment files!
class cl_abap_char_utilities definition load.

Best regards.

0 Kudos

hi pablo casamayor thank you very much for your kindly hint reagrding the class.

Can you please explain me that more detailed.

Regards

sas

0 Kudos

Hi,

in your development after the TABLES declaration do:

e.g.

  • This is the tables declaration

TABLES: spfli.

  • This is the class declaration

class cl_abap_char_utilities definition load.

Best regards.

Former Member
0 Kudos

pablo casamayor this is not what I am asking for.

Is it necessary to implement the class although

CL_ABAP_CHAR_UTILITIES is a SAP class.

If so can you please describe or show how must it

impelmented and overwrited ?

Regards

sas

0 Kudos

Not Necessarily. you can do it this way as well.

REPORT  ztest.
TYPE-POOLs: abap.
CONSTANTS: horizontal_tab TYPE  abap_char1  VALUE %_HORIZONTAL_TAB,
           cr_lf          TYPE  abap_cr_lf  VALUE  %_CR_LF.

DATA s_test TYPE string.
s_test = 'afafdfd#retretertre#vmnmnmnmmnbnm#'.

REPLACE ALL OCCURENCES OF horizontal_tab IN s_test WITH cr_lf.

Hope this Helps.

A

0 Kudos

Hi,

go to transaction SE24 and see if class CL_ABAP_CHAR_UTILITIES exists.

If it does exist then it´s only necessary to declare the class.

By the way, what´s your SAP System version?

Best regards.

Former Member
0 Kudos

I am using release SAP ECC 6.0.

Yes this class is existing but I dont understand what you mean

exactly.

Pablo to sum up:

I need a way on how to replace # with new line

or line feed.

I have the following command but it returns not the

correctly result.


data s_test type string.
s_test = 'afafdfd#retretertre#vmnmnmnmmnbnm#'.
REPLACE ALL OCCURRENCES OF '#' IN s_test WITH CL_ABAP_CHAR_UTILITIES=>CR_LF.
write: s_test.

result:

afafdfd##retretertre##vmnmnmnmmnbnm##

0 Kudos

Hi,

have a look at this:

http://www.sap-img.com/abap/string-handling-in-abap-removing-unwanted-char.htm

This is another option:

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/c924b874-0a01-0010-9192-b31f007a...

e.g.


l_input = '12345678'. l_regex = '([0-9])(?=([0-9]{3})+(?![0-9]))'. l_new = '$1.'. 
REPLACE ALL OCCURRENCES OF REGEX l_regex IN l_input WITH l_new.
This will insert a thousandu2019s separator

Best regards.

Edited by: pablo casamayor on Aug 1, 2008 5:49 PM

Edited by: pablo casamayor on Aug 1, 2008 5:56 PM

0 Kudos

Hi,

try something like:


report ztest.

data s_test(255) type c.
data : ln type i.
data : pos type i.

s_test = 'afafdfd#retretertre#vmnmnmnmmnbnm#'.

ln = strlen( s_text ).

do ln times.
pos = sy-index - 1 .

if s_text+pos(1) = '#'.
 s_text+pos(1) = CL_ABAP_CHAR_UTILITIES=>CR_LF.
endif.


enddo.


write 😕 s_test.

Best regards.

Edited by: pablo casamayor on Aug 1, 2008 6:15 PM

0 Kudos

I think CL_ABAP_CHAR_UTILITIES=>CR_LF have a value # then in that case why you are replacing the # with #

For testing this try to change all "a" in the string with cr_lf.


data s_test type string.
s_test = 'afafdfd#retretertre#vmnmnmnmmnbnm#'.
REPLACE ALL OCCURRENCES OF 'a' IN s_test WITH CL_ABAP_CHAR_UTILITIES=>CR_LF.
write: s_test.

0 Kudos

a®s

thanks a lot of this clarification. Is it really true

that # is line feed.

If so how can I remove # and anyhow linefeeds.

The Requirement is to remove cross hatch without

deleting the linefeeds. Because if you have e.g. such

a text:

Radovan Karadzic trying to submit a letter##to the war crimes tribunal alleging u201Cirregularitiesu201D in his##treatment. The text reads u201CWould the registrar##please take this?u201D

It is not looking nice. Is there no way solve this problem

0 Kudos

As for as i know we could not differentiate the cross hash and line feed.

May be try to remove all # with space and split the string into multiple chunks


report  zars.
data s_test type string.
constants : c_ash(2) type c value '##'.
s_test = 'Radovan Karadzic trying to submit a letter##to the war crimes tribunal alleging #irregularities# in his##treatment. The text reads #Would the registrar##please take this?#'.
replace all occurrences of c_ash in s_test with space.
write: s_test.

But then also your requirement will not fulfilled

a®s

Edited by: a®s on Aug 1, 2008 1:34 PM

Former Member
0 Kudos

pablo casamayor thanks but at your above given example

I get the same result as privous.

output is
afafdfd#retretertre#vmnmnmnmmnbnm#

nothing is replaced

Former Member
0 Kudos

Is it possible to do the foolowing:

Remove at first # and insert exactly there one linefeed.

Thus it is realized to not display ## and having also

linefeed. Can please illustriate that adjustment as

abap code ?

rgds

sas

0 Kudos

I'm arriving late into this thread, but the # character you see could be one of several unprintable characters - SAP just prints the # to show this situation... (you can look in debug to see the actual hex value of the #)

One solution to the original question could be to do something like (not syntax checked):


data:
  l_delimit(1)     type c,
  l_line(100)      type c,
  lt_line          like l_line,
  l_test           type string.

l_delimit = '#'.  "or set to CR-LF or whatever your # is 
l_test = 'afafdfd#retretertre#vmnmnmnmmnbnm#'.

split l_test at l_delimit into table lt_line.
loop at lt_line into l_line.
  write: / l_line.
endloop.

which should give something like


afafdfd
retretertre
vmnmnmnmmnbnm

... or did I miss the point of the question?

Jonathan

former_member705122
Active Contributor
0 Kudos

Hi Erdem,

Note:

The CR/LF characters cannot be displayed on ABAP lists or screens.

Check this sample code,

*------------------------------------------------------------------*
CLASS cl_abap_char_utilities DEFINITION LOAD.

TYPES:
  BEGIN OF type_itab,
    w_char(100) TYPE C,
  END OF type_itab.

DATA:
  itab  TYPE TABLE OF type_itab WITH HEADER LINE.

itab = 'SIMPLE#TEST##EXAMPLE'.

REPLACE ALL OCCURRENCES OF '#' IN itab WITH
cl_abap_char_utilities=>cr_lf.

APPEND itab.

CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
   filename        = 'd	emp	est.txt'
   filetype        = 'ASC'
  TABLES
    data_tab       = itab.
*Result:----------------------------------------------------------*
*       SIMPLE
*       TEST
*
*       EXAMPLE
*-----------------------------------------------------------------*

For more info check you are previous thread,

link:

Regards

Adil