09-11-2007 6:12 AM
Hi
I am using FM 'GUI_DOWNLOAD' to download the data in Excel format. Now i am able to download the data in proper format bur unable to download the header of the columns. Can anyone have solution to this??
09-21-2007 2:50 PM
Yes, it is possible to download column headers with GUI_DOWNLOAD. To do this,
you must provide the parameter FIELDNAMES with a corresponding table:
This table must be a single-line table.
The following is a corresponding "showcase" source code:
REPORT reportname.
" Declaration of Line Type: SPFLI *
TYPES: BEGIN OF line_type,
field1 LIKE spfli-carrid,
field2 LIKE spfli-connid,
field3 LIKE spfli-cityfrom,
END OF line_type.
" Declaration of Table Type *
TYPES tab_type TYPE STANDARD TABLE OF line_type.
" Declaration of internal Table *
DATA: itab TYPE tab_type.
" Declaration of workarea *
DATA: wa TYPE line_type.
" Declaration of Fieldnames *
DATA: BEGIN OF colnames OCCURS 0,
col(10) TYPE c,
END OF colnames.
" One Colname per line *
colnames-col = 'Column1'. APPEND colnames.
colnames-col = 'Column2'. APPEND colnames.
colnames-col = 'Column3'. APPEND colnames.
START-OF-SELECTION.
" Get the data and fill the workarea *
SELECT carrid connid cityfrom
FROM spfli
INTO (wa-field1, wa-field2, wa-field3).
APPEND wa TO itab.
ENDSELECT.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
" Now download the itab with fieldnames: *
" By using dat_mode and fieldseparator *
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:\TEMP\test.txt'
filetype = 'ASC'
dat_mode = 'X'
write_field_separator = 'X'
TABLES
data_tab = itab
fieldnames = colnames
EXCEPTIONS
OTHERS = 1.
if sy-subrc <> 0.
message i398(00) with 'Error: ' sy-subrc 'during gui_download!'.
endif.