06-04-2013 3:03 PM
Hi,
I need to these two sentences in a string. Can anybody tell me how to do this?
For example:
data: var_string(50) type c.
var_string = 'my first line
my second line'.
It returns an error, of course. But I need to be able to write the following when I write the var_string variable:
my first line
my second line
Thanks in advance.
Regards.
06-04-2013 3:09 PM
Hello ,
Try this
Concatenate 'My first line' cl_abap_char_utilities=>cr_lf 'My second line' into var_string.
Cheers
Abhinab
06-04-2013 3:10 PM
Hi,
Try this for cl_abap_char_utilities=>cr_lf linefeed. Similarly for others, you can check the class->attributes of cl_abap_char_utilities.
concatenate 'my first line' cl_abap_char_utilities=>cr_lf 'my second line' into var_string.
06-04-2013 3:38 PM
06-04-2013 3:11 PM
You could "play" with CL_ABAP_CHAR_UTILITIES=>CR_LF in a concatenation, but you will only get some ## junk character with statement WRITE, so you must use two "WRITE / text." or a "WRITE: / text1, / text2." syntax.
DATA: text1 TYPE c LENGTH 30 VALUE 'ABDCDEFGHIJ',
text2 TYPE c LENGTH 30 VALUE 'ZYXWVUTSRQP',
text TYPE c LENGTH 132.
CONCATENATE text1 cl_abap_char_utilities=>cr_lf text2 INTO text SEPARATED BY ` `.
WRITE: / text.
WRITE: / text1, / text2.
Regards,
Raymond
06-04-2013 3:46 PM
Ok.
Actually I haven't explained the goal of the cr and lf. Once I've the cr and lf between both lines and the string saved in a char variable, I call this sentence:
CALL FUNCTION 'GUI_DOWNLOAD'
passing this variable.
So, I need to get the
'my first line
my second line'
in my var_variable variable, if possible, of course.
Thanks.
06-04-2013 3:51 PM
Okay, in this case notepad should display the downloaded text as you wish.
(But same result can be achieved by inserting two lines in DATA_TAB parameter and setting parameter WRITE_LF too.)
Regards,
Raymond
06-04-2013 4:03 PM
I'm using notepad to see the downloaded text but I only see the first line..
Any suggestion why I don't see the second line?
06-05-2013 7:14 AM
Hi,
As mentioned, you can simply add two records as well in internal table and use write_lf = 'X' in gui_download.
lv_string = 'First line'.
append lv_string to lt_string.
lv_string = 'Second line'.
append lv_string to lt_string.
cl_gui_frontend_services=>gui_download( EXPORTING filename = <lv_filename>
write_lf = 'X'
filetype = 'ASC'
changing data_tab = lt_string
EXCEPTIONS ....).
06-05-2013 6:39 AM
data: lv_string(50) type c.
Concatenate : 'My first line' CL_ABAP_CHAR_UTILITIES=>NEWLINE 'My second line' INTO lv_string.
You wont get the output in multi line with WRITE statement, it will give just '##", because, WRITE statement doesn't print this content in the desired way.
You can download that string in the text file to see the output.
06-05-2013 6:53 AM
types l_string(50) type c.
data : lt_string type STANDARD TABLE OF l_string.
data : lv_string type l_string.
Concatenate : 'My first line' CL_ABAP_CHAR_UTILITIES=>CR_LF 'My second line' INTO lv_string.
append lv_string to lt_string.
cl_gui_frontend_services=>gui_download( EXPORTING filename = 'C:\Documents and Settings\susmitha\Desktop\test1.txt'
filetype = 'ASC'
changing data_tab = lt_string
EXCEPTIONS others = 24 ).