Warning: include_once(http://erpgenie.com/_borders/topabap.htm) [function.include-once]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /var/www/vhosts/erpgenie.com/httpdocs/abaptips/templates/rhuk_solarflare_ii/index.php on line 52

Warning: include_once() [function.include]: Failed opening 'http://erpgenie.com/_borders/topabap.htm' for inclusion (include_path='.:') in /var/www/vhosts/erpgenie.com/httpdocs/abaptips/templates/rhuk_solarflare_ii/index.php on line 52

Login

Login to view more content!!!





Lost Password?
No account yet? Register

Registered Access

Poll

What area of ABAP are you interested in?
 
Home arrow Sample Code arrow ABAP OO arrow Sample program for OLE Automation
Sample program for OLE Automation PDF Print E-mail
User Rating: / 0
PoorBest 
Written by Anon.   
Friday, 23 February 2007
* Including OLE types
INCLUDE OLE2INCL.
TABLES: CUSTOMERS.
DATA: APPLICATION TYPE OLE2_OBJECT,
      WORKBOOK    TYPE OLE2_OBJECT,
      SHEET       TYPE OLE2_OBJECT,
      CELLS       TYPE OLE2_OBJECT.
* Creating an object
CREATE OBJECT APPLICATION 'excel.application'.
IF SY-SUBRC NE 0.
   WRITE: / 'Error when opening excel.application', SY-MSGLI.
ENDIF.
* Setting properties
SET PROPERTY OF APPLICATION 'Visible' = 1.
* Calling methods
CALL METHOD OF APPLICATION 'Workbooks' = WORKBOOK.
CALL METHOD OF WORKBOOK 'Add'.
CALL METHOD OF APPLICATION 'Worksheets' = SHEET EXPORTING #1 = 1.
CALL METHOD OF SHEET 'Activate'.
PERFORM FILL_SHEET.

* Subroutine for filling the spread sheet
FORM FILL_SHEET.
  DATA: ROW_MAX TYPE I VALUE 256,
        INDEX   TYPE I.
  FIELD-SYMBOLS: <NAME>.
  SELECT * FROM CUSTOMERS.
    INDEX = ROW_MAX * ( SY-DBCNT - 1 ) + 1.
    DO 4 TIMES.
      ASSIGN COMPONENT SY-INDEX OF STRUCTURE CUSTOMERS TO <NAME>.
      CALL METHOD OF SHEET 'Cells' = CELLS
                           EXPORTING #1 = INDEX.
      SET PROPERTY OF CELLS 'Value' = <NAME>.
      ADD 1 TO INDEX.
    ENDDO.
  ENDSELECT.
ENDFORM.
* Subroutine for error handling
FORM ERRORS.
  IF SY-SUBRC NE 0.
    WRITE: / 'Error in OLE call', SY-MSGLI.
    EXIT.
  ENDIF.
ENDFORM.

Related Items:

 
< Prev   Next >

Google Search

Statistics

Contribution Activity
Utilities: 38
Tips and Tricks: 333
Sample Code: 164
Total Contributions: 550

Member Activity
Members: 6244 since 2/1/2007!
New: 0 since yesterday!
Visitors: 1080589
We have 1 guest online

Newest Members

Welcome our newest members:

Google Ads


Warning: include(http://erpgenie.com/_borders/bottom.htm) [function.include]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /var/www/vhosts/erpgenie.com/httpdocs/abaptips/includes/footer.php on line 22

Warning: include() [function.include]: Failed opening 'http://erpgenie.com/_borders/bottom.htm' for inclusion (include_path='.:') in /var/www/vhosts/erpgenie.com/httpdocs/abaptips/includes/footer.php on line 22