2008 Jan 22 9:09 AM
Hi,
i got a Small problem. I have to Concatenate two Strings and Separated them with a New Line but i couldn't find anything to get this done.
My test Code looks like this :
DATA: test1 TYPE String,
test2 TYPE String,
test3 TYPE string.
test1 = 'Hallo'.
test2 = 'du da'.
CONCATENATE test1 test2 INTO test3 SEPARATED BY space.
WRITE test3.
This works so far but i need to replace space with something to get a new Line.
Maybe someone had an idea.
Greetings
Moritz
2008 Jan 22 10:43 AM
Hi Mortiz,
Please check below:
data: l_cr(1) type c value cl_abap_char_utilites=>cr_lf,
l_lf(1) type c value cl_abap_char_utilities=>linefeed.
One of the above will certainly help you. Am not on SAP now to check the same. Use this for concatenating.
CONCATENATE str1 str2 INTO out SEPARATED BY l_cr.
CONCATENATE str1 str2 INTO out SEPARATED BY l_lf.
Kind Regards
Eswar
2008 Jan 22 10:43 AM
Hi Mortiz,
Please check below:
data: l_cr(1) type c value cl_abap_char_utilites=>cr_lf,
l_lf(1) type c value cl_abap_char_utilities=>linefeed.
One of the above will certainly help you. Am not on SAP now to check the same. Use this for concatenating.
CONCATENATE str1 str2 INTO out SEPARATED BY l_cr.
CONCATENATE str1 str2 INTO out SEPARATED BY l_lf.
Kind Regards
Eswar
2008 Jan 22 10:46 AM
Hmm,
i didn't have the Class cl_abap_char_utilities :/. We got a SAP R3 4.6 C. i could not find any similar class so far :-/.
greetings
Moritz
2008 Jan 22 10:52 AM
Hi,
Try this..
DATA: V_HEX TYPE X VALUE '0D'. "Carriage return.
DATA: V_CHAR(50).
CONCATENATE 'LINE1' 'LINE2' INTO V_CHAR SEPARATED BY V_HEX.
Regards,
Satish
2008 Jan 22 10:53 AM
Mortiz,
In that case you need to declare as below.
>data: l_tab(1) type X value '09'
Value 09 denoted tab character, similarly you need to get the value for NEW LINE.
Sorry cant remember the exact code. Try to get the ascii character for the same.
Regards
Eswar
2008 Jan 22 10:57 AM
Thanks for your help,
but both "Code" brings me a '#' between the two Strings.
Im a little bit Confused :-(.
Greetings
Moritz
2008 Jan 22 11:01 AM
Hi Mortiz
If you are checking in debug mode, it will be visible as '#'.
Try downloading the same to a file and then test the output.
Regards
Eswar
2008 Jan 22 11:19 AM
Hi,
Try this
DATA: NEWLINE(2) TYPE X VALUE '0D0A'
DATA: V_CHAR(50).
CONCATENATE 'LINE1' 'LINE2' INTO V_CHAR SEPARATED BY NEWLINE.
Regards,
Satish
2008 Jan 22 11:27 AM
2021 Jul 28 7:54 AM
I am not using 7.4 version can help me with same code in ECC
2021 Jul 28 8:21 AM
2021 Jul 28 9:01 AM
vinay_krishna and it probably works in version ABAP 4.6C too. Please start a new question if you want discussing, people usually don't reply on comments on old questions. Good bye.
2008 Jan 22 11:00 AM
Hi,
u just try like this
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.
rgds,
bharat.
2008 Jan 22 11:05 AM
hi,
try it
data: l_cr(1) type c value cl_abap_char_utilities=>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.
L.Velu
2008 Jan 22 11:11 AM
Hmm if i download it to a file it works, but the Problem is i have to show the result in SAP.
In a Message Box and there i got the "#" or for sy-uline(5) i got "-----" :-/.
So i seperate the two Strings with a space.
This works but dint look nice, but its the only way to solve it at the moment.
Thanks for your great help.
Greetings
Moritz
2008 Mar 29 7:25 PM
Hai
There is small error in this code,
when using concatenate operator ,
CONCATENATE C1 C2 ....CN INTO STR1 BY H.
H should be Character type either C ,N,D,T or String.
In your program,
you are declaring line_br(2) type X.
so, it gives that error.
you should correct your code in either way like
DATA: line_br(4) TYPE C VALUE '0D0A'.
OR
DATA: line_br TYPE STRING VALUE '0D0A'.
DATA: v_line TYPE string.
CONCATENATE 'LINE1' 'LINE2' INTO v_line SEPARATED BY line_br.
Then it works.
if it useful, reward points.
Thank you,
G.V.K.Prasad