Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Convert internal table to excel without downloading

Former Member
0 Kudos

I have an internal table which i want to store as an excel file into a Z table (contents xstring or binary).

Is it possible to do that without downloading?

Thanks in adv.

2 REPLIES 2

former_member229729
Active Participant
0 Kudos

Hi Aishi Sharma,

There are 2 methods:

1. Using Function Module:

Call Function Module:

MOVE 'C:\FILE2.XLS' TO V_FILE.
 
       CALL FUNCTION 'GUI_DOWNLOAD'
       EXPORTING
           FILENAME              = V_FILE
           FILETYPE              = 'DAT'
           WRITE_FIELD_SEPARATOR = 'X'
      TABLES
           DATA_TAB              =  ITAB.

2. Using OLE Method:

REPORT  testexcel          .
 
INCLUDE ole2incl.
 
DATA: application TYPE ole2_object,
       workbook TYPE ole2_object,
       sheet TYPE ole2_object,
       cells TYPE ole2_object.
 
CONSTANTS: row_max TYPE i VALUE 256.
DATA index TYPE i.
 
 
 
DATA: BEGIN OF itab1 OCCURS 0,
 first_name(10),
 last_name(10),
 END OF itab1.
 
START-OF-SELECTION.
 
 itab1-first_name = '123445'.
 itab1-last_name = 'tesst'.
 append itab1.
 clear itab1.
 
 
 
 itab1-first_name = '123446'.
 itab1-last_name = 'tesst'.
 append itab1.
 clear itab1.
 
 
 
  CREATE OBJECT application 'excel.application'.
  SET PROPERTY OF application 'visible' = 1.
  CALL METHOD OF application 'Workbooks' = workbook.
  CALL METHOD OF workbook 'Add'.
 
 
 
* Create first Excel Sheet
 
  CALL METHOD OF application 'Worksheets' = sheet
                               EXPORTING #1 = 1.
 
  CALL METHOD OF sheet 'Activate'.
  SET PROPERTY OF sheet 'Name' = 'Sheet1'.
 
  LOOP AT itab1.
    index = row_max * ( sy-tabix - 1 ) + 1. " 1 - column name
    CALL METHOD OF sheet 'Cells' = cells EXPORTING #1 = index.
 
    SET PROPERTY OF cells 'Value' = itab1-first_name.
        index = index + 1. " 1 - column name
    CALL METHOD OF sheet 'Cells' = cells EXPORTING #1 = index.
    SET PROPERTY OF cells 'Value' = itab1-last_name.
  ENDLOOP.
 
 
* Save excel speadsheet to particular filename
 CALL METHOD OF sheet 'SaveAs'
 
                  EXPORTING #1 = 'c:tempexceldoc1.xls'     "filename
 
                            #2 = 1.                          "fileFormat

Hope you are answered.

Rgds,

Ramani N.

Edited by: Ramani Nagarajan on Jun 6, 2009 5:55 AM

Former Member
0 Kudos

Aishi,

Is there any reason you can not do direct Internal table update in Z Table.

There are some SAP Function module which can help you with Conversion serach with


*XSTING* 
*BINARY*