‎2008 Jan 30 5:15 AM
Hi Experts!!
I want to concatenate two strings but there should be change in line after 1st string. Is it possible to create a string that concatenates the two strings separated with a new line.
For example string1 and string2 is to be concatenated in string3 as:-
string1
string2
Thanks in advance..
Prabhas Jha
‎2008 Jan 30 5:58 AM
prabha,
Try this
DATA: NEWLINE(2) TYPE X VALUE '0D0A'
DATA: V_CHAR(50).
CONCATENATE LINE1 LINE2 INTO V_CHAR SEPARATED BY NEWLINE.
(OR)
DATA: test1 TYPE String,
test2 TYPE String,
test3 TYPE string.
test1 = 'Hallo'.
test2 = 'du da'.
CONCATENATE test1 sy-uline(5) test2 INTO test3 SEPARATED BY space.
WRITE test3.
Don't forget to reward if useful...
‎2008 Jan 30 5:24 AM
Hi
DATA: gv_line_space(256) type c.
CONCATENATE string1 gv_line_space string2 into string3.
Write: string3.
Just check the output..u need to adjust the width of gv_line_space so that the output comes as desired by you.
Cheers
Shakir
‎2008 Jan 30 5:53 AM
hi,
find out the length of the string1 then minus it through 256
then concatenate this much spaces back to the string1 and then concatenate string2 back to string1.
then try to display the string1.
your problem will be solved.
thanks
Dharmishta
‎2008 Jan 30 5:58 AM
prabha,
Try this
DATA: NEWLINE(2) TYPE X VALUE '0D0A'
DATA: V_CHAR(50).
CONCATENATE LINE1 LINE2 INTO V_CHAR SEPARATED BY NEWLINE.
(OR)
DATA: test1 TYPE String,
test2 TYPE String,
test3 TYPE string.
test1 = 'Hallo'.
test2 = 'du da'.
CONCATENATE test1 sy-uline(5) test2 INTO test3 SEPARATED BY space.
WRITE test3.
Don't forget to reward if useful...
‎2008 Jan 30 6:30 AM
for this u should dynamically calculate the line width as per 1st strings value.
And in the concatenation part the line space should be also calculated as per the line width calculation mentioned above.
‎2008 Jan 30 6:18 AM
Hi all..
I tried using a new string ,string3(200) and concatenated with the strings.
Concatenate string1 string4(200) string2 into string3.
But in the output it is not adding the spaces. In fact it just ignores string4.
What can be the reason..I have to concatenate by this method.
Thanks..
Prabhas
‎2008 Jan 30 7:04 AM
concatenate
string1 string2 into result_string separated by cl_abap_char_utilities=>cr_lf .
‎2008 Jan 30 7:49 AM
hi Durairaj,
In place of creating a new line, ## has been inserted in between the strings,if i use cl_abap_char_utilities=>cr_lf .
‎2008 Jan 30 7:55 AM
if you write the string to ABAP list or view the string in debugger, thats how it will show up. however if you pass this string to any text editor it would properly split it and show it in two lines.
Regards
Raja
‎2008 Jan 30 7:58 AM
Hi,
Do like this
data: l_cr(1) type c value cl_abap_char_utilites=>cr_lf,
l_lf(1) type c value cl_abap_char_utilities=>linefeed.
CONCATENATE str1 str2 INTO out SEPARATED BY l_cr.
CONCATENATE str1 str2 INTO out SEPARATED BY l_lf.
If your Version is 4.6C, do like this
DATA: NEWLINE(2) TYPE X VALUE '0D0A'
DATA: V_CHAR(50).
CONCATENATE 'LINE1' 'LINE2' INTO V_CHAR SEPARATED BY NEWLINE.
Regards,
Satish
‎2008 Feb 02 12:17 PM
hi...
I tried using both the methods..
for the first method,
cl_abap_char_utilites=>cr_lf is not recognized by system.
for second method my version is ecc6.0, so it is unable to recognize type 'X'.
i tried by concatenating a blank variable with space...But that does not work as well!!
‎2011 Jun 20 12:43 PM
Hi Experts,
How to Use the Concatenation Statement.
Regards,
Santosh Ballyapelli
‎2011 Jun 20 3:42 PM
why not read your ABAP Help (F1) for the concatenate statement?
‎2011 Jun 20 4:41 PM
For example string1 and string2 is to be concatenated in string3 as:-
string1
string2
Why do you want to concatenate?
Take 2 separate strings in your operations instead of concatenating.
eg:
write:/ String1
write:/ String2
‎2013 Jan 19 6:33 AM
Nothing to Do.
Just Write 'SEPARATED BY SPACE' At the end of Concatenate statement.
thanks.
reward if it is useful.
‎2015 Sep 23 10:09 AM