You are on page 1of 3

Working with Excel in ABAP

Enterprise Resource
Planning Portal

Enterprise Resource
Planning Portal

Google Search
Web
ERPGenie Menu

ERPGenie.
COM
Consultant Corner

Client Corner

Advertise | BLOG

Home | Vote for us | 401

ERPGenie.COM -> SAP Technical -> ABAP -> Example code -> Working with Excel

REPORT ZZBGS010 .
*----------------------------------------------------------------------*
* Example: Interface between Microsoft Excel and ABAP/4 with up- and
*
* downloading of data plus executing Microsoft Excel.
*
*----------------------------------------------------------------------*
TABLES: USR04.
DATA: SIZE TYPE I.
DATA: BEGIN OF USER OCCURS 100.
INCLUDE STRUCTURE USR04.
DATA: END OF USER.
* ---------------------------------------------------------------------*
* Example: Select some data into an internal table.
*
* ---------------------------------------------------------------------*
SELECT * FROM
*
*
*
*

ERP Related Menu

USR04 INTO TABLE USER .

---------------------------------------------------------------------*
Example: Downloading data in Microsoft Excel Format with automatic
*
prompt popup dialog.
*
---------------------------------------------------------------------*

http://www.erpgenie.com/abap/code/abap42.htm (1 of 3)11/27/2007 12:21:23 PM

Working with Excel in ABAP

CALL FUNCTION 'DOWNLOAD'


EXPORTING
FILENAME
= 'C:\tmp\SAPEXL1.XLS'
FILETYPE
= 'WK1'
"ASC, WK1, DBF, DAT, bin
MODE
= ' '
"Mode ' ' = Rewrite Mode 'A' = Appending
TABLES
DATA_TAB
= USER.
*
*
*
*

---------------------------------------------------------------------*
Example: Downloading data in Microsoft Excel Format without automatic*
prompt popup.
*
---------------------------------------------------------------------*
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
FILENAME
= 'C:\tmp\SAPEXL2.XLS'
FILETYPE
= 'WK1'
"ASC, WK1, DBF, DAT, bin
MODE
= ' '
"Mode ' ' = Rewrite Mode 'A' = Appending
TABLES
DATA_TAB
= USER.

CLEAR USER.
REFRESH USER.

"Clear buffer
"Refresh, empty internal table

*----------------------------------------------------------------------*
* Example: Uploading Microsoft Excel to ABAP/4 internal table.
*
*----------------------------------------------------------------------*
CALL FUNCTION 'UPLOAD'
EXPORTING
FILENAME = 'C:\tmp\SAPEXL.prn'
FILETYPE = 'ASC'
IMPORTING
FILESIZE = SIZE
TABLES
DATA_TAB = USER.
*----------------------------------------------------------------------*
* Example: Starting Microsoft Excel and load sheet.
*
*----------------------------------------------------------------------*
CALL FUNCTION 'WS_EXECUTE'
EXPORTING
COMMANDLINE
= 'C:\tmp\SAPEXL1.XLS'
PROGRAM
= 'F:\APPL\WINDOWS\EXCEL5DK\EXCEL.EXE'
.
*----------------------------------------------------------------------*
* Example: Starting Microsoft Excel and load internal table as sheet
*
*----------------------------------------------------------------------*
http://www.erpgenie.com/abap/code/abap42.htm (2 of 3)11/27/2007 12:21:23 PM

Working with Excel in ABAP

CALL FUNCTION 'WS_EXCEL'


EXPORTING
FILENAME = 'C:\tmp\SAPEXL.XLS'
SYNCHRON = ' '
TABLES
DATA
= USER.
-------------------------------------------------------------------------------Contact Us | Polls | Add URL | Contribute | About | Privacy | Terms | Feedback | Help!
Message Board | Discussion Forum | BLOG | Consultants: Post your resume | Companies: Advertise on ERPGenie.COM | Post Job
20012006 ERPGenie.COM, Inc. All rights reserved.
All product names are trademarks of their respective companies. ERPGenie.COM, Inc. is in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver, and and any other SAP trademarks are registered trademarks of SAP AG in Germany and in several other countries.
Every effort is made to ensure content integrity. Use information on this site at your own risk.

http://www.erpgenie.com/abap/code/abap42.htm (3 of 3)11/27/2007 12:21:23 PM

You might also like