2007 Feb 05 10:53 AM
hi,
I want down load the data into Excel sheet with every field descriptions when i execute the Report,
regards
Suresh.D
2007 Feb 05 11:00 AM
HI,
Use the FM:
<b>MS_EXCEL_OLE_STANDARD_OLE</b> will build a file, and automatically start Excel
or
<b>RH_START_EXCEL_WITH_DATA</b> starts Excel with the contents of an internal table. This function finds Excel in the desktop registry. It also uses a local PC working directory to save the file (that's what the 'W' value for data path flag does). Very transparent to user!
or
<b>WS_EXCEL</b> Start EXCEL on the PC .
Hope this helps.
Reward if helpful.
Regards,
Sipra
2007 Feb 05 10:56 AM
Hi Suresh,
Use the function module: GET_COMPONENT_LIST to get the field descriptions for the internal table.
MOve those descriptions as the first line of the table that is being downloaded. and use the function mofule GUI_DOWNLOAD.
Regards,
Ravi
2007 Feb 05 11:00 AM
HI,
Use the FM:
<b>MS_EXCEL_OLE_STANDARD_OLE</b> will build a file, and automatically start Excel
or
<b>RH_START_EXCEL_WITH_DATA</b> starts Excel with the contents of an internal table. This function finds Excel in the desktop registry. It also uses a local PC working directory to save the file (that's what the 'W' value for data path flag does). Very transparent to user!
or
<b>WS_EXCEL</b> Start EXCEL on the PC .
Hope this helps.
Reward if helpful.
Regards,
Sipra
2007 Feb 05 12:15 PM
2007 Feb 05 12:49 PM
Hi,
You can use the following logic.I used the same its working fine.
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
default_extension = 'xls'
default_file_name = l_file
CHANGING
filename = l_file
path = l_path
fullpath = l_fullpath
user_action = l_act
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
OTHERS = 3.
IF sy-subrc EQ 0 AND l_act = 0 AND NOT l_file IS INITIAL.
CALL METHOD cl_gui_frontend_services=>file_exist
EXPORTING
file = l_fullpath
RECEIVING
result = l_return
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
wrong_parameter = 3
OTHERS = 4 .
IF sy-subrc = 0 AND NOT l_return IS INITIAL.
CALL METHOD cl_gui_frontend_services=>file_delete
EXPORTING
filename = l_fullpath
CHANGING
rc = l_rc
EXCEPTIONS
file_delete_failed = 1
cntl_error = 2
error_no_gui = 3
file_not_found = 4
access_denied = 5
unknown_error = 6
OTHERS = 7 .
IF sy-subrc <> 0.
MESSAGE i000(zm) WITH "Problem while deleting the file'.
EXIT.
ENDIF.
ENDIF.
REFRESH: t_kpi, t_header.
wa_header-bukrs = text-h01.
wa_header-kdate = text-h02.
wa_header-waers = text-h03.
APPEND wa_header TO t_header.
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
filename = l_fullpath
write_field_separator = c_x
CHANGING
data_tab = t_header .
IF sy-subrc = 0.
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
filename = l_fullpath
append = c_x
write_field_separator = c_x
CHANGING
data_tab = t_kpi .
IF sy-subrc = 0.
MESSAGE i000(zm) WITH text-e12 space space space.
ELSE.
MESSAGE i000(zm) WITH text-e13 space space space.
ENDIF.
ELSE.
MESSAGE i000(zm) WITH text-e13 space space space.
ENDIF.
ELSE.
MESSAGE i000(zm) WITH text-e14 space l_date space.
ENDIF.
ENDIF.
2007 Feb 05 1:06 PM
2007 Feb 05 1:11 PM
hi
to achive this u can use the GUI_DOWNLOAD...
only the extra effort is u have to do pass the talbe <b>FIELDNAMES</b>...
for this create a internal table with 1 field size of 40 characters..then append the headings u want... suppose if have 10 fields in u r output internaltabl(L_IT_FIELDNAMES) .. then u append 10 record to this itab.. with the headers u want then pass this as follwos
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = 'C:xxxxx.XLS'
WRITE_FIELD_SEPARATOR = L_C_X
TABLES
DATA_TAB = L_IT_EXCEL
FIELDNAMES = L_IT_FIELDNAMES
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
2007 Feb 05 2:00 PM
Hi Suresh ,
1) First define an internal table for field desc as -
DATA: BEGIN OF I_OUTPUT_FIELDS OCCURS 0,
TITLE(25) ,
END OF I_OUTPUT_FIELDS.
2) append it with requird header as -
I_OUTPUT_FIELDS-TITLE = 'Purchasing Docment'.
APPEND I_OUTPUT_FIELDS.
CLEAR I_OUTPUT_FIELDS.
3) while downloading use that internal table as
CALL FUNCTION 'EXCEL_OLE_STANDARD_DAT'
EXPORTING
FILE_NAME = P_FILE
TABLES
DATA_TAB = I_FINAL
FIELDNAMES = I_OUTPUT_FIELDS
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.
ENDIF.
I think this will serve your purpose.
Narayan