‎2008 Mar 14 8:30 AM
Hello Experts,
Please help me find some function module or an alternative to create an excel sheet onto my desktop with the data passed from the internal table.
‎2008 Mar 14 8:35 AM
Hi Keerthi,
The FM GUI_DOWNLOAD wil help u for this
Please reward if useful
Thanks Arjun
‎2008 Mar 14 8:36 AM
‎2008 Mar 14 8:37 AM
Also if you require titles in excel sheet,
try ws_download. (though it is obsolute it still works.)
also
try in se37 ..ole_excel* it will give you a fm to down load in excel
‎2008 Mar 14 8:37 AM
declarations
data:
l_filename like rlgrap-filename,
wa_x030l like x030l,
tb_dfies type standard table of dfies,
wa_dfies type dfies,
begin of tb_flditab occurs 0,
field description
fldname(40) type c,
end of tb_flditab.
get table/structure field info
call function 'GET_FIELDTAB'
exporting
langu = sy-langu
only = space
tabname = i_tabname
withtext = 'X'
importing
header = wa_x030l
tables
fieldtab = tb_dfies
exceptions
internal_error = 01
no_texts_found = 02
table_has_no_fields = 03
table_not_activ = 04.
check result
case sy-subrc.
when 0.
copy fieldnames
loop at tb_dfies into wa_dfies.
case i_desc_type.
when 'F'.
tb_flditab-fldname = wa_dfies-fieldname.
when 'S'.
tb_flditab-fldname = wa_dfies-scrtext_s.
when 'M'.
tb_flditab-fldname = wa_dfies-scrtext_m.
when 'L'.
tb_flditab-fldname = wa_dfies-scrtext_l.
when others.
use fieldname
tb_flditab-fldname = wa_dfies-fieldname.
endcase.
append tb_flditab.
clear variables
clear: wa_dfies.
endloop.
when others.
message id sy-msgid type sy-msgty number sy-msgno
with sy-subrc raising error_get_dictionary_info.
endcase.
export (and open) file to MS-Excel
call function 'EXCEL_OLE_STANDARD_DAT'
exporting
file_name = i_filename
data_sheet_name = 'Data'
tables
data_tab = i_tb_data
fieldnames = tb_flditab
exceptions
file_not_exist = 1
filename_expected = 2
communication_error = 3
ole_object_method_error = 4
ole_object_property_error = 5
invalid_filename = 6
invalid_pivot_fields = 7
download_problem = 8
others = 9.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 raising error_excel_ole.
endif.
REWARD POINTS IF HELPFUL,
KUMAR
‎2008 Mar 14 8:39 AM
‎2008 Mar 14 8:39 AM
Hi,
Try this one out.
DATA: file_name TYPE string value 'C:\TEXT.XLS'.,
file_type(10) TYPE c VALUE 'ASC'.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = file_name
filetype = file_type
TABLES
data_tab = itab
EXCEPTIONS
file_write_error = 1
invalid_type = 2
no_batch = 3
unknown_error = 4
gui_refuse_filetransfer = 5
OTHERS = 6.
where ITAB holds values u want to store on ur EXCEL SHEET.
Regards,
Balakumar.G.
Reward points if helpful.
‎2008 Mar 14 8:42 AM
hi,
Try out with these FM's
EXCEL_OLE_STANDARD_DAT Starts Excel and transfers internal table data
MS_EXCEL_OLE_STANDARD_DAT Builds a file and automatically starts Excel
RH_START_EXCEL_WITH_DATA Starts Excel with contents of an internal table
SAP_CONVERT_TO_XLS_FORMAT Downloads internal table to Excel
Hope this helps, Do reward.
‎2008 Mar 14 8:42 AM
Hello
You can use following FM
CALL FUNCTION 'XXL_FULL_API'
EXPORTING
filename = 'ZZ_SALE'
no_dialog = space
n_att_cols = h_count
n_hrz_keys = 1
n_vrt_keys = v_count
sema_type = 'X'
TABLES
data = xmplt_d
hkey = xmplt_h
online_text = xmplt_o
print_text = xmplt_p
sema = xmplt_s
vkey = xmplt_v
EXCEPTIONS
cancelled_by_user = 1
data_too_big = 2
dim_mismatch_data = 3
dim_mismatch_sema = 4
dim_mismatch_vkey = 5
error_in_hkey = 6
error_in_sema = 7
file_open_error = 8
file_write_error = 9
inv_data_range = 10
inv_winsys = 11
inv_xxl = 12
OTHERS = 13.
where
xmplt_d : required data
xmplt_h : row heading
xmplt_s : EXCEL schema.
Reward points if helpful.
Regards,
Rahul
‎2015 Jun 03 8:59 AM
Hi,
When using function GUI_DOWNLOAD, FILENAME = e.g. 'c\:test.xls', if set import parameter FILETYPE = 'ASC', open the excel file you created, you will get message "The file format and extension of 'test.xls' don't match. The file could be corrupted or unsafe. Unless you trust its source, don't open it. Do you want to open it anywya?" You can just ignore the message and proceed.
If set FILETYPE = 'DBF', you won't get such a message.
Regards,
Wenjing