01-29-2007 9:54 PM
Hi,
I am trying to write data in a file using separated by ',' keyword, so that the data when written in Excel file using GUI_DOwnload, will separate the fields. But the problem is all the data is separated by comma in just one row of excel file.
LOOP AT it_itab.
IF sy-tabix = 1.
v_string = it_itab-name.
ELSE.
CONCATENATE v_string it_itab-name INTO v_string separated by ','.
ENDIF.
ENDLOOP.
APPEND v_string TO it_string.
ENDIF.
IF v_string IS NOT INITIAL.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:\temp.xls'
TABLES
data_tab = it_string
EXCEPTIONS
file_write_error = 1
no_batch = 2.
But I want to get each data on each separate row.
For example now I am getting ,
row1: Data1, data2, data3... in one row of Excel
But I need in the form:
row1: Data1
row2: Data2
row3: Data3
:
:
01-29-2007 10:20 PM
Hi,
Instead of using comma as a separator, declare a varaiable as shown below and use it. It will download data in multiple columns in an excel.
CONSTANTS : c_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.
Reward points if the answer is helpful.
Regards,
Mukul
01-29-2007 10:07 PM
Hi Rajesh,
Declare an internal table then append the data from v_string to internal table & after that pass the internal table to GUI_download using tab as field searator. It will work.
Ashven
01-29-2007 10:18 PM
As you can see I am already doing what you suggested:
APPEND v_string TO it_string.
But it does not work.I et the data in different columns but I want in different rows...
01-29-2007 10:23 PM
01-29-2007 10:28 PM
I need to use
CONSTANTS : c_tab TYPE c VALUE cl_abap_char_utilities=>NEWLINE.
Thanks for all the help, gurus...
01-29-2007 10:14 PM
Hi,
Instead of
LOOP AT it_itab.
IF sy-tabix = 1.
v_string = it_itab-name.
ELSE.
CONCATENATE v_string it_itab-name INTO v_string separated by ','.
ENDIF.
ENDLOOP.
APPEND v_string TO it_string.
ENDIF.
use
LOOP AT it_itab.
IF sy-tabix = 1.
v_string = it_itab-name.
ELSE.
CONCATENATE v_string it_itab-name INTO v_string separated by ','.
ENDIF.
APPEND v_string TO it_string.
ENDLOOP.
Regards,
Vara
01-29-2007 10:20 PM
Hi,
Instead of using comma as a separator, declare a varaiable as shown below and use it. It will download data in multiple columns in an excel.
CONSTANTS : c_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.
Reward points if the answer is helpful.
Regards,
Mukul
01-29-2007 10:25 PM
Hi,
In GUI_DOWNLOAD pass the parameter WRITE_FIELD_SEPARATOR 'X'...Then in the excel you see it in different columns..
DOWNLOAD THE DATA.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:\TEST.XLS'
<b>WRITE_FIELD_SEPARATOR = 'X'</b>
tables
data_tab = ITAB
THanks,
Naren
01-29-2007 10:28 PM
01-29-2007 10:29 PM
With the supplied code, all you need is to make the file extension .csv instead of .xls, if you want the file to be comma delimited.
data: it_string type table of string.
data: v_string type string.
LOOP AT it_itab.
IF sy-tabix = 1.
v_string = it_itab-name.
ELSE.
CONCATENATE v_string it_itab-name INTO v_string separated by ','.
ENDIF.
ENDLOOP.
APPEND v_string TO it_string.
ENDIF.
IF it_string IS NOT INITIAL. "<- Change here
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:temp.csv' "<- Change here
TABLES
data_tab = it_string
EXCEPTIONS
file_write_error = 1
no_batch = 2.
Regards,
RIch Heilman
01-29-2007 10:35 PM