06-02-2014 8:24 AM
Good Day Experts.
I am trying to download excel file using function module GUI_DOWNLOAD.
declared a table it_string type table string.
initially I appending my header to it_string. and then passing my internal table to it .
this is how I am passing data into it_string.
so in gui_download I am passing parameters as below. but I am not getting data into the excel file.
I tried both ways passing field separator as 'X' and '#'.
please guide me where I am wrong.
06-02-2014 9:52 AM
Hi,
Make sure that the data is uploading into the internal table it_string,debug and check once.
Please check the following link,it may be helpful
Downloading internal tables to Excel - ABAP Development - SCN Wiki
Thanks & Regards,
Sravanthi Polu
06-02-2014 9:52 AM
Hi,
Make sure that the data is uploading into the internal table it_string,debug and check once.
Please check the following link,it may be helpful
Downloading internal tables to Excel - ABAP Development - SCN Wiki
Thanks & Regards,
Sravanthi Polu
06-02-2014 10:32 AM
Hello Surendra,
Can you please upload your code sample. Thanks.
What i manage to find is using this function module WS_DOWNLOAD.
The file is downloaded in the directory --> C:/
Here is the code sample :
TABLES: usr03,dd02l.
DATA: zx030l LIKE x030l.
DATA BEGIN OF zdfies OCCURS 0.
INCLUDE STRUCTURE dfies.
DATA END OF zdfies.
DATA: BEGIN OF flditab OCCURS 0,
fldname(11) TYPE c,
END OF flditab.
DATA itabusr03 LIKE usr03 OCCURS 0 WITH HEADER LINE.
DATA tname LIKE dd02l-tabname.
SELECT * FROM usr03 INTO TABLE itabusr03.
tname = 'USR03'.
PERFORM getfieleds.
PERFORM dwdbffile.
********************************************
FORM getfieleds.
CALL FUNCTION 'GET_FIELDTAB'
EXPORTING
langu = sy-langu
only = space
tabname = tname
withtext = 'X'
IMPORTING
header = zx030l
TABLES
fieldtab = zdfies
EXCEPTIONS
internal_error = 01
no_texts_found = 02
table_has_no_fields = 03
table_not_activ = 04.
CASE sy-subrc.
WHEN 0.
LOOP AT zdfies.
flditab-fldname = zdfies-fieldname.
APPEND flditab.
ENDLOOP.
WHEN OTHERS.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-subrc.
ENDCASE.
ENDFORM. "GETFIELEDS
***********************************
FORM dwdbffile.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
* filename = 'C:\USR03.DBF'
filename = 'C:\USR03.XLS'
filetype = 'DBF'
TABLES
data_tab = itabusr03
fieldnames = flditab
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
OTHERS = 10.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. "DWDBFFILE
Thanks and Kind Regards,
Yovish.
06-02-2014 11:11 AM
Hi Surendra ,
Few things -
1. Use New line Character - Concatenate wa_string cl_abap_char_utilities=>New_line to wa_string before append wa_string to it_string.
2. Are able to download the xls file ? First try with XLS file format
3. As you mentioned 'First appending Header to It_string' , Not able to see part in attached screenshot
Thanks & Regards,
Arun
06-03-2014 7:22 AM
Good Day
thanks for the replies to all.
I have resolve the issue by making all fields in table as characters and passed my header as first record.
but I couldn't achieve it by creating a dynamic table as table type string. I debugged it and noticed the data is going fine. it is going as below example
aal0#comany#1234# as I concatenated every field separated by tab.
but the output is coming as null.
loop at itab_w assigning <dyn_wa>.
do
.
assign component sy-index of structure <dyn_wa> to <dyn_field>.
if sy-subrc = 0.
exit.
endif.
if sy-index = 1.
l_str = <dyn_flied>.
else.
concatenate l_str <dyn_field> into l_str separated by cl_abap_chat_utilities=>horizontal_tab.
endif.
endo.
append l_str to it_str.
endloop.
in call function gui_download I am passing the file type as 'DBF'
file name 'c:\ testdata.xls'.
field separator = '#'
tables
data_tab = it_str