‎2009 May 25 9:57 AM
‎2009 May 25 10:09 AM
‎2009 May 25 10:40 AM
Dear,
Can you elaborate your problem little more so that we can understand exact problem.
Regards,
Vijay
‎2009 May 25 10:47 AM
Ok, I am looking for code to export data from a table which is live to a spreadsheet when SAP goes down. For the information to be available even when SAP is down.
I hope it makes sense and thanks.
‎2009 May 25 11:13 AM
Hi,
Please try below URL.
/people/kathirvel.balakrishnan2/blog/2006/05/08/data-upload-into-sap-from-microsoft-excel-150-abap-part
Regards
Pugal.
‎2009 May 26 10:46 AM
This example is more than 25char so i give in multiple thread
REPORT ZOLE_ABAP.
INCLUDE ole2incl.
TYPES: BEGIN OF ty_spfli,
kunnr TYPE kna1-kunnr,
land1 TYPE kna1-land1,
NAME1 TYPE KNA1-NAME1,
ORT01 TYPE KNA1-ORT01,
REGIO TYPE KNA1-REGIO,
ADRNR TYPE KNA1-ADRNR,
END OF ty_spfli.
TYPES: BEGIN OF ty_titles,
title(20) TYPE c,
field(20) TYPE c,
END OF ty_titles.
DATA: t_spfli TYPE STANDARD TABLE OF ty_spfli,
t_titles TYPE STANDARD TABLE OF ty_titles.
FIELD-SYMBOLS: <fs_spfli> LIKE LINE OF t_spfli,
<fs_titles> LIKE LINE OF t_titles,
<fs> TYPE ANY.
DATA: w_tabix TYPE sy-tabix,
w_titles TYPE sy-tabix,
w_line TYPE sy-tabix,
w_field TYPE string,
filename TYPE string,
path TYPE string,
fullpath TYPE string.
DATA: data_titles TYPE REF TO data.
DATA: e_sheet TYPE ole2_object,
e_activesheet TYPE ole2_object,
e_newsheet TYPE ole2_object,
e_appl TYPE ole2_object,
e_work TYPE ole2_object,
e_cell TYPE ole2_object,
e_color TYPE ole2_object,
e_bold TYPE ole2_object.
SELECTION-SCREEN BEGIN OF BLOCK b1.
PARAMETERS: p_file TYPE rlgrap-filename.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
PERFORM get_titles.
PERFORM get_data.
PERFORM create_excel.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
window_title = 'Select archivo'
default_extension = 'xls'
file_filter = '*.xls'
CHANGING
filename = filename
path = path
fullpath = fullpath.
IF sy-subrc EQ 0.
p_file = fullpath.
ENDIF.
‎2009 May 26 10:47 AM
FORM get_titles.
CREATE DATA data_titles TYPE ty_titles.
ASSIGN data_titles->* TO <fs_titles>.
<fs_titles>-title = 'Customer Number 1'.
<fs_titles>-field = 'KUNNR'.
APPEND <fs_titles> TO t_titles.
<fs_titles>-title = 'Country Key'.
<fs_titles>-field = 'LAND1'.
APPEND <fs_titles> TO t_titles.
<fs_titles>-title = 'Name 1'.
<fs_titles>-field = 'NAME1'.
APPEND <fs_titles> TO t_titles.
<fs_titles>-title = 'City'.
<fs_titles>-field = 'ORT01'.
APPEND <fs_titles> TO t_titles.
<fs_titles>-title = 'Region'.
<fs_titles>-field = 'REGIO'.
APPEND <fs_titles> TO t_titles.
<fs_titles>-title = 'Address'.
<fs_titles>-field = 'ADRNR'.
APPEND <fs_titles> TO t_titles.
ENDFORM. "get_titles
FORM get_data.
SELECT KUNNR LAND1 NAME1 ORT01 REGIO ADRNR
INTO TABLE t_spfli
FROM KNA1
WHERE LAND1 EQ 'IN'
and KUNNR EQ '0000700008'.
ENDFORM. " get_data
FORM create_excel.
w_line = 1.
CREATE OBJECT e_appl 'EXCEL.APPLICATION'.
SET PROPERTY OF e_appl 'VISIBLE' = 1.
CALL METHOD OF e_appl 'WORKBOOKS' = e_work.
CALL METHOD OF e_work 'Add' = e_work.
GET PROPERTY OF e_appl 'ActiveSheet' = e_activesheet.
SET PROPERTY OF e_activesheet 'Name' = 'Customer Details'.
LOOP AT t_spfli ASSIGNING <fs_spfli>.
w_tabix = sy-tabix.
w_line = w_line + 1.
LOOP AT t_titles ASSIGNING <fs_titles>.
w_titles = sy-tabix.
CALL METHOD OF e_appl 'Cells' = e_cell
EXPORTING
#1 = 1
#2 = w_titles.
SET PROPERTY OF e_cell 'Value' = <fs_titles>-title.
GET PROPERTY OF e_cell 'Interior' = e_color.
SET PROPERTY OF e_color 'ColorIndex' = 35.
GET PROPERTY OF e_cell 'Font' = e_bold.
SET PROPERTY OF e_bold 'Bold' = 1.
CALL METHOD OF e_appl 'Cells' = e_cell
EXPORTING
#1 = w_line
#2 = w_titles.
CONCATENATE '<fs_spfli>-' <fs_titles>-field
INTO w_field.
ASSIGN (w_field) TO <fs>.
SET PROPERTY OF e_cell 'Value' = <fs>.
GET PROPERTY OF e_cell 'Interior' = e_color.
SET PROPERTY OF e_cell 'ColumnWidth' = 20.
SET PROPERTY OF e_color 'ColorIndex' = 0.
GET PROPERTY OF e_cell 'Font' = e_bold.
SET PROPERTY OF e_bold 'Bold' = 0.
ENDLOOP.
ENDLOOP.
‎2009 May 26 10:48 AM
CALL METHOD OF e_work 'SAVEAS'
EXPORTING
#1 = p_file.
CALL METHOD OF e_work 'close'.
CALL METHOD OF e_appl 'QUIT'.
FREE OBJECT e_appl.
ENDFORM. " create_excel