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

String Concatenation

Former Member
0 Likes
463

hi all,

is it possible to concatenate string with character new line ?

for example, i have one variable : 'lv_string'

if i write the variable to screen with syntax :

write : / lv_string.

the result will be like this :

hello

world

is there any way ?

please help

regards

eddhie

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
430

Hi eddhie,

1. Unfortunately

WRITE statement does not work with NEW LINE character.

2. At most it will display this new line character

as #.

3. It will show like this

hello#world.

4. What can be done is that,

the string can be SPLIT at

new line character,

into an internal table.

5. Then we can loop at this internal table,

and use WRITE 😕 itab-fieldname.

regards,

amit m.

4 REPLIES 4
Read only

Former Member
0 Likes
431

Hi eddhie,

1. Unfortunately

WRITE statement does not work with NEW LINE character.

2. At most it will display this new line character

as #.

3. It will show like this

hello#world.

4. What can be done is that,

the string can be SPLIT at

new line character,

into an internal table.

5. Then we can loop at this internal table,

and use WRITE 😕 itab-fieldname.

regards,

amit m.

Read only

0 Likes
430

hi Amit,

thanks for the reply.

yes, i have tried with CL_ABAP_CHAR_UTILITIES class and the result in the screen will be '#'.

the problem is i want to write the variable to a smartforms. at certain condition the text value will be 'A' and at the other condition the text value should be 'B'. i have used the CL_ABAP_CHAR_UTILITIES class to do that but character '#' will appear instead of NEW LINE CHARACTER.

unfortunately, i'm newbie in smartforms and the documentation about smartforms that i got is not much help.

is there any way i can do that in smartforms ?

please help

regards

Read only

Former Member
0 Likes
430

write:/ 'hello'.

write:/ 'world'.

Read only

Former Member
0 Likes
430
CLASS CL_ABAP_CHAR_UTILITIES DEFINITION LOAD.
CONSTANTS: C_CR_LF  TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF.

CONCATENATE 'helo'
            'world'
            INTO V_STR separated by C_CR_LF.

this will work only if we download it to either presentation server or application server. then only we can see the line break betwen 'HELO' and 'world'.

if your requirement is just to print,

you can use,

write 😕 'helo'.

write 😕 'world'.

regards

srikanth

Message was edited by: Srikanth Kidambi

Message was edited by: Srikanth Kidambi