‎2006 May 19 2:11 PM
Hello Experts,
I have TWO problem, kindly help me out with them.
We need to download the internal table to a CSV or an XLS File. I am not able to find a Function Module for downloading to EXCEL but GUI_UPLOAD works good enough for CSV format. Kindly let me know a relevant FM for
downloading data to XLS file.
While downloading data to CSV file, I am facing following problem. The Problem with GUI_UPLOAD is that if there is a comma(,) in the data of any field then it is splitted into two columns while passing to the CSV file since the seperator to differentiate between different columns is comma(,).
Thanks in advance.
‎2006 May 19 2:14 PM
‎2006 May 19 2:19 PM
Which are you doing, download or upload? You can use the GUI_UPLOAD/GUI_DOWNLOAD functions with excel, make sure that you set the HAS_FIELD_SEPARATOR parameter to "X".
If you are working with comma delimited files, use GUI_UPLOAD to upload into a flat structure, then loop at this internal table and use the SPLIT statement to split the data into columns.
Regards,
Rich Heilman
‎2006 May 19 2:15 PM
SEND_TABLE_TO_EXCEL
And there are more FM just search for EXCEL in SE37.
Regards
Aman
‎2006 May 19 2:16 PM
hii
<b>Download into CSV format from internal table
SAP_CONVERT_TO_TEX_FORMAT or
SAP_CONVERT_TO_CSV_FORMAT .
in SAP_CONVERT_TO_CSV_FORMAT ,the import parameter I_FIELD_SEPARATOR = ';' by default irrespective of whatever we pass .
type-pools: truxs.
DATA : BEGIN OF itab OCCURS 0,
name1(10),
name2(10),
END OF itab.
DATA : itab1 TYPE truxs_t_text_data.
DO 10 TIMES.
itab-name1 = 'Prabhu'.
itab-name2 = 'Rajesh'.
APPEND itab.
CLEAR : itab.
ENDDO.
LOOP AT itab.
WRITE:/ itab-name1, itab-name2.
ENDLOOP.
CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
EXPORTING
i_field_seperator = ';'
I_LINE_HEADER =
i_filename =
I_APPL_KEEP = ' '
TABLES
i_tab_sap_data = itab
CHANGING
I_TAB_CONVERTED_DATA = itab1
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.</b>
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
filename = 'd:\cps_data1.xls'
filetype = 'DAT'
mode = 'A'
TABLES
data_tab = intab
EXCEPTIONS
file_open_error = 1
file_write_error = 2
invalid_filesize = 3
invalid_type = 4
no_batch = 5
unknown_error = 6
invalid_table_width = 7
gui_refuse_filetransfer = 8
customer_error = 9
no_authority = 10
OTHERS = 11
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
chk this link
http://www.sapdevelopment.co.uk/file/file_upexcel.htm
Message was edited by: Naresh Kumar
‎2006 May 19 2:23 PM
GUI_DOWNLOAD is good enough to download data from internal table to excel sheet.
See the below code:
data : t_mard type standard table of mard.
select * from mard
into table t_mard up to 100 rows.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = 'C:\test.xls'
FILETYPE = 'DAT'
TABLES
DATA_TAB = t_mard.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
‎2006 May 19 2:42 PM
Hi Giri,
Use this following FM
1) ws_download
2) GUI_download
This may work for your requirement
Thanks
Sunil.