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

line break in string

Former Member
0 Likes
24,658

I want to make a line break in a string. Is this possible??

In Java it looks like "Hello

World".

The Output will look like

Hello

World

Greetings Volker

Edited by: Volker Schäfer on Jan 3, 2008 4:55 PM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
12,230

try this....

REPORT ZSAMPLE. .

start-of-selection.

write: 'hello', /1 'world'.

Reward points if useful.

14 REPLIES 14
Read only

Former Member
0 Likes
12,230

Hello Volker,

is your requirement to have it in one string?

Otherwise you can use the write statement:

write: 'Hello',

/ 'World'.

Best regards

Stephan

Read only

0 Likes
12,230

Yes in one String. I want to give a paramter string to another program und this makes write STRING

and the output is

Hello

World

Read only

0 Likes
12,230

we can declare a variable with value '/OD' hex value and concatenate to get a line break..

data: lv_line_feed type X value 'OD'

or

09.

Read only

0 Likes
12,230

I try this, but it don´t work. Type x? Can you write the exact code please? Thank you very much!

Read only

0 Likes
12,230

data:word(10) type c.

start-of-selection.

word = 'HelloWorld'.

write: word+0(5).

write:/ word+5(5).

Read only

Former Member
0 Likes
12,230

I seyrch something like:

data test type string value 'test'.

data linebreak ?????

concatenate test linebreak test

Read only

Former Member
0 Likes
12,230

data: ch type string.

data: ch1(2) type c.

ch1 = CL_ABAP_CHAR_UTILITIES=>CR_LF.

concatenate 'abc' 'def' into ch seperated by ch1.

write:/ ch.

it will display like abc##def.

the ## means line break here...

Read only

0 Likes
12,230

I really get the output abc##def. But what is the profit of this for me??

Edited by: Volker Schäfer on Jan 4, 2008 10:16 AM

Read only

0 Likes
12,230

Friend,

OK Sir, please don't mind...

One more way is there...try this...

data: itab2 type table of string.

data: str type string value 'Hello World'.

split str at space into table itab2.

loop at itab2 into str.

write:/ str.

endloop.

Read only

0 Likes
12,230

in ABAP the line break is done by '/'.

so where ever it finds '/' in the write statement it goes to next line....it user decision to locate the position to be splitted.

you can do it this way too

data:word(10) type c.

data:word_length type i.

start-of-selection.

word = 'HelloWorld'.

word_length = strlen( word ).

if word_length > 5.

write: word+0(5).

write:/ word+5(word_length).

else.

write: word+0(5).

endif.

Read only

Former Member
0 Likes
12,231

try this....

REPORT ZSAMPLE. .

start-of-selection.

write: 'hello', /1 'world'.

Reward points if useful.

Read only

0 Likes
12,230

Mr aruls post seemes to be more better

Read only

0 Likes
12,230

This are good ideas, but i want to give a string into a smartform and for this the line break must be "in the string". It must be possible in abap to do this like in Java:

String test = "hello""/n""world";

Or is this not possible?

Greetings Volker

Read only

0 Likes
12,230

I GUESS ITS NOT POSSIBLE...

BUT I THINK SO ITS POSSIBLE TO FORMAT THE STRING IN THE SMART FORM CODE.