11-22-2008 5:05 AM
I was able to download data from internal table to Excel File using GUI_DOWNLOAD.
However i would like to add first line of excel sheet with Field name Details.
for eg if below is excel sheet, it should display Field name and under that all field values.
Customer Number Country City
0000000001 India Hy
0000000002 US NJ
0000000003 Uk NS
etc..
How do i go about it ?
I tried searching in SDN, but no luck. help me on this.
Thanks
11-24-2008 5:09 AM
data:begin of it_heading occurs 0,
text(20) type c,
end of excel_heading.
it_heading-text = 'Customer Number'.
append it_heading.
it_heading-text = 'Country'.
append it_heading.
it_heading-text = 'City'.
append it_heading.
call function 'GUI_DOWNLOAD'
exporting
filename = p_pfile
filetype = 'DAT'
write_field_separator = '#'
header = '00'
trunc_trailing_blanks = 'X'
show_transfer_status = 'X'
tables
data_tab = p_it_final[]
fieldnames = it_heading[]. <----
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
11-23-2008 11:58 AM
Hi,
What's the data type of fields in your internal table? Is it char or string? If yes just try the following way.
You define your internal table which will be download as 3 fields type string. And first append one
header record of three fields: 'Customer' 'Number' 'Country City' to the internal table, then append data
record to the internal table. After that call 'GUI_DOWNLOAD' to download the table to excel.
11-23-2008 12:16 PM
hi,
use OLE rather than gui_download.
many examples are present how to download the data in excel sheet with column headings search in sdn with the keyword OLE you will get the answer.
For your assistance check the below link
https://www.sdn.sap.com/irj/scn/advancedsearch?query=ole+heading&cat=sdn_all
Cheers!!
VEnk@
11-24-2008 5:09 AM
data:begin of it_heading occurs 0,
text(20) type c,
end of excel_heading.
it_heading-text = 'Customer Number'.
append it_heading.
it_heading-text = 'Country'.
append it_heading.
it_heading-text = 'City'.
append it_heading.
call function 'GUI_DOWNLOAD'
exporting
filename = p_pfile
filetype = 'DAT'
write_field_separator = '#'
header = '00'
trunc_trailing_blanks = 'X'
show_transfer_status = 'X'
tables
data_tab = p_it_final[]
fieldnames = it_heading[]. <----
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
11-24-2008 11:26 AM