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: 

WRITE string with line break inside string.

daniel_humberg
Contributor
0 Kudos

I would like to add a line break into a string that I want to write with the WRITE statement, but without using SKIP or NEWLINE or WRITE: \.


CONCATENATE 'part1'
            ?the_line_break?
            'part2'
  INTO lv_string.
WRITE lv_string.

Any idea?

9 REPLIES 9

former_member223537
Active Contributor
0 Kudos

Hi Daniel,

CONCATENATE 'part1'

cl_abap_char_utilities=>line_feed

'part2'

INTO lv_string.

WRITE lv_string.

Best regards,

Prashant

0 Kudos

cl_abap_char_utilities=>line_feed does not exist.

And cl_abap_char_utilities=>newline or cl_abap_char_utilities=>cr_lf don't work. They are just written as '##'.

0 Kudos

Hi ,

Use this : data: newline(2) TYPE x VALUE '0D0A'.

or just assign '/' to a constant and use it or you can go for cl_abap_char_utilities=>newline or cl_abap_char_utilities=>cr_lf , if you are using a unicode system environment.

Regards,

Raghav

0 Kudos

'0D0A' is only displayed as '0D0A'.

newline and cr_lf are displayed as '##'.

'/' is only displayed as '/'.

Does this mean that I am on a non-unicode system?

Message was edited by: Daniel Humberg

0 Kudos

>>Does this mean that I am on a non-unicode system?

You can check it using the menu <i>system--> status</i>

look out for the value yes/no in the field <i>Unicode System</i>

~Suresh

0 Kudos

It says

Unicode System: "No".

0 Kudos

Interesting requirement..

WRITE statement does not interpret OS line break codes.

You've to program to induce line break, try the following example code.

data: lv_string(20),

lv_off type i.

concatenate 'part1'

'~'

'part2'

into lv_string.

search lv_string for '~'.

lv_off = sy-fdpos + 1.

write: at 1(sy-linsz) lv_string0(sy-fdpos), lv_stringlv_off.

Regards

Sridhar

0 Kudos

hai,

try this,

class cl_abap_char_utilities definition load.

constants: c_tab type c value

cl_abap_char_utilities=>crlf.

*chech exact method in above class for carriage return and line feed

CONCATENATE 'text1' c_tab 'text2' c_tab 'text3' into gd_result.

write gd_result.

0 Kudos

Hi loeiz,

as I said, cl_abap_char_utilities=>cr_lf does not work.

I now found a solution that is similar to Sridhar soluion.


CONCATENATE 'text1' '~~~' 'text2' c_tab 'text3' 
  INTO lv_string. 
SPLIT lv_string AT '~~~' INTO TABLE lt_stringtab .

LOOP AT lt_stringtab INTO lv_string.
  WRITE / lv_string.
ENDLOOP.