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

WRITE string with line break inside string.

daniel_humberg
Advisor
Advisor
0 Likes
4,034

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
Read only

Former Member
0 Likes
2,755

Hi Daniel,

CONCATENATE 'part1'

cl_abap_char_utilities=>line_feed

'part2'

INTO lv_string.

WRITE lv_string.

Best regards,

Prashant

Read only

0 Likes
2,755

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

Read only

0 Likes
2,755

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

Read only

0 Likes
2,755

'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

Read only

0 Likes
2,755

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

Read only

0 Likes
2,755

It says

Unicode System: "No".

Read only

0 Likes
2,755

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

Read only

0 Likes
2,755

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.

Read only

0 Likes
2,755

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.