2007 Dec 20 1:24 PM
My requirement downloads internal table data to Excel sheet with column headings (i.e. descriptions) . I am using GUI_DOWNLOAD for this. This is OK. But the problem is Excel sheet should contains column headings in place of first row (i.e. A, B, C, D.............). If this possible, pls provide logic.
Thanks in advance.
Naseer.
My requirement downloads internal table data to Excel sheet with column headings (i.e. descriptions) . I am using GUI_DOWNLOAD for this. This is OK. But the problem is Excel sheet should contains column headings in place of first row (i.e. A, B, C, D.............). If this possible, pls provide logic.
Thanks in advance.
Naseer.
2007 Dec 20 1:37 PM
2007 Dec 20 2:03 PM
Hi naseer
try this code..
DATA : BEGIN OF itab OCCURS 0,
matnr LIKE eban-matnr,
menge LIKE eban-menge,
END OF itab.
DATA : BEGIN OF fld_tab OCCURS 0,
title(30),
END OF fld_tab.
fld_tab-title = 'Material'.
APPEND fld_tab.
fld_tab-title = 'Quantity'.
APPEND fld_tab.
SELECT matnr menge INTO TABLE itab FROM eban
UP TO 50 ROWS
WHERE matnr NE space.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:\TEMP\DATA.XLS'
write_field_separator = 'X'
TABLES
data_tab = itab
fieldnames = fld_tab.
2007 Dec 20 2:21 PM
Hi Naseer,
Check this code yaar. Might be it helps you.
TABLES: T001.
data: it_t001 type t001 occurs 0,
it_fields type dfies occurs 0 with header line,
*DFIES
*DD Interface: Table Fields for DDIF_FIELDINFO_GET
begin of it_fnames occurs 0,
reptext like dfies-reptext,
end of it_fnames.
dfies-reptext REPRESENTS HEADDINGS OF FIELDS.
The structure definition required for this internal table.
The following definition is not working:
it_fnames like dfies-reptext occurs 0 with header line.
because Function Module will use the following:
ASSIGN COMPONENT 1 OF STRUCTURE FIELDNAMES TO <F>.
select * from t001 into table it_t001.
CALL FUNCTION 'GET_FIELDTAB'
EXPORTING
LANGU = SY-LANGU
ONLY = ' '
TABNAME = 'T001'
WITHTEXT = 'X'
IMPORTING
HEADER =
RC =
TABLES
FIELDTAB = it_fields
EXCEPTIONS
INTERNAL_ERROR = 1
NO_TEXTS_FOUND = 2
TABLE_HAS_NO_FIELDS = 3
TABLE_NOT_ACTIV = 4
OTHERS = 5
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
loop at it_fields.
it_fnames-reptext = it_fields-reptext.
append it_fnames.
endloop.
CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'
EXPORTING
FILE_NAME = 'C:\test.xls'
CREATE_PIVOT = 0
DATA_SHEET_NAME = 'sheet1'
PIVOT_SHEET_NAME = ' '
PASSWORD = ' '
PASSWORD_OPTION = 0
TABLES
PIVOT_FIELD_TAB =
DATA_TAB = it_t001
FIELDNAMES = it_fnames
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.
ENDIF.
Reward points,if useful.
Regards,
Manoj Kumar
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |