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

MERGE VARIABLE IN STRING TEMPLATE WITH BREAK ROW

Former Member
0 Likes
1,345

HI,

i try merge between 2 variables with new row.

my code:

CONSTANTS: c_delimiter(1) TYPE c VALUE cl_abap_char_utilities=>newline.

DATA: var1 TYPE string,
      var2 TYPE string,
      varout TYPE string.

var1 = 'hi'.
var2 = 'hello'.


CONCATENATE var1 var2 INTO varout SEPARATED  BY C_DELIMITER.

WRITE varout.

and i get result like this:

string-var.png

and i want get:

hi
hello.

thanks.

HI,

i try merge between 2 variables with new row.

my code:

CONSTANTS: c_delimiter(1) TYPE c VALUE cl_abap_char_utilities=>newline.

DATA: var1 TYPE string,
      var2 TYPE string,
      varout TYPE string.

var1 = 'hi'.
var2 = 'hello'.


CONCATENATE var1 var2 INTO varout SEPARATED  BY C_DELIMITER.

WRITE varout.

and i get result like this:

string-var.png

and i want get:

hi
hello.

thanks.

3 REPLIES 3
Read only

former_member30
Product and Topic Expert
Product and Topic Expert
0 Likes
1,266

Hi and welcome to the SAP Community!

Thank you for visiting SAP Community to get answers to your questions. Since you're asking a question here for the first time, I recommend that you familiarize yourself with https://community.sap.com/resources/questions-and-answers (if you haven't already), as it provides tips for preparing questions that draw responses from our members. For example, you can outline what steps you took to find answers (and why they weren't helpful) and share screenshots of what you've seen/done. The more details you provide, the more likely it is that members will be able to assist you.

Should you wish, you can revise your question by selecting Actions, then Edit (although once someone answers your question, you'll lose the ability to edit the question -- but if that happens, you can leave more details in a comment).

Finally, if you're hoping to connect with readers, please consider adding a picture to your profile. Here's how you do it: https://www.youtube.com/watch?v=F5JdUbyjfMA&list=PLpQebylHrdh5s3gwy-h6RtymfDpoz3vDS. By personalizing your profile with a photo of you, you encourage readers to respond.

Cheers,
Julia
SAP Community Moderator

Read only

Abinathsiva
Active Contributor
1,266

Hi,

Try with below code


CONSTANTS: c_delimiter(1) TYPE c VALUE cl_abap_char_utilities=>cr_lf.

DATA: var1 TYPE string,
      var2 TYPE string,
      varout TYPE string.

var1 = 'hi'.
var2 = 'hello'.


CONCATENATE var1 var2 INTO varout SEPARATED  BY C_DELIMITER.

WRITE varout.

or sy-uline also can help...

Read only

MateuszAdamus
Active Contributor
1,266

Hello alon121

The result you get is correct. # in the result represent a non-visible character, in this case a new line. WRITE statement prints multi line texts in one line. Just as it did in your result.

If you want to print a new line you need to use WRITE /.

Kind regards,
Mateusz