Skip to Content
avatar image
Former Member

express CR_LF

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

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

9 Answers

  • Best Answer
    avatar image
    Former Member
    Aug 01, 2008 at 03:20 PM

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

    Add comment
    10|10000 characters needed characters exceeded

    • 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

  • avatar image
    Former Member
    Aug 01, 2008 at 11:11 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 01, 2008 at 10:42 AM

    '#' 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 .

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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 .

  • avatar image
    Former Member
    Aug 01, 2008 at 11:00 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 01, 2008 at 11:42 AM

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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 01, 2008 at 02:44 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 01, 2008 at 05:03 PM

    pablo casamayor thanks but at your above given example

    I get the same result as privous.

    output is
    afafdfd#retretertre#vmnmnmnmmnbnm#

    nothing is replaced

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 01, 2008 at 06:12 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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

  • avatar image
    Former Member
    Aug 02, 2008 at 08:44 AM

    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:

    impact-or-effect-of-clabapcharutilitiesnewline

    Regards

    Adil

    Add comment
    10|10000 characters needed characters exceeded