17.08.2013 Views

Data Interfaces

Data Interfaces

Data Interfaces

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Programming Example in ABAP/4<br />

l Example transaction in R/3: OLE<br />

l<br />

© SAP AG<br />

INCLUDE OLE2INCL.<br />

DATA: EXCEL TYPE OLE2_OBJECT.<br />

DATA: BOOKS TYPE OLE2_OBJECT.<br />

DATA: CELL TYPE OLE2_OBJECT.<br />

DATA: FILENAME(50) = 'C:\TEMP\OLE1.XLS'.<br />

DATA: VALUE(10).<br />

CREATE OBJECT EXCEL 'EXCEL.APPLICATION'.<br />

SET PROPERTY OF EXCEL 'VISIBLE' = 1.<br />

CALL METHOD OF EXCEL 'WORKBOOKS' = BOOKS.<br />

CALL METHOD OF BOOKS 'OPEN' EXPORTING #1 = FILENAME #2 = 1.<br />

GET PROPERTY OF EXCEL 'ACTIVECELL' = CELL.<br />

GET PROPERTY OF CELL 'VALUE' = VALUE.<br />

WRITE: / 'Value:', VALUE.<br />

CALL METHOD OF EXCEL 'QUIT'.<br />

FREE OBJECT CELL.<br />

FREE OBJECT BOOKS.<br />

FREE OBJECT EXCEL.<br />

The Transaction OLE is an example of OLE client functionality of ABAP/4 in the R/3 System. It allows<br />

you direct access to the desktop applications MS Word, Excel and Visio.<br />

Usage example for Excel:<br />

The "Start" button generates the Excel application object and activates the application window.<br />

There should be an Excel file on your PC. Please enter the complete path of this file in the document<br />

area.<br />

The "Edit File" button opens the specified file for processing in the Excel application object. At the<br />

same time, it generates a spreadsheet object and activates the menu bars and the tools of the desktop<br />

application.<br />

The "Get Cell" button copies the contents of the active call in Excel to the field in the SAP data area.<br />

You can then change this value and write it back to the active cell in Excel with "Transfer".<br />

The "Release" button releases the OLE object<br />

If you change the Excel sheet with "Transfer", Excel notes this and displays another dialog box for you<br />

to confirm whether you want to save the modified file.<br />

The example report RS41504A implements the above ABAP/4 code.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!