ABAPCALL_METHOD_OLE2 - CALL METHOD OLE2
RFUMSV00 - Advance Return for Tax on Sales/Purchases ABAP Short ReferenceThis documentation is copyright by SAP AG.
CALL METHOD - OLE
Syntax
CALL METHOD OF ole meth [= rc]
[EXPORTING p1 = f1 p2 = f2 ...]
[NO FLUSH] [QUEUE-ONLY].
Additions
1.... EXPORTING p1 = f1 p2 = f2 ...
2.... NO FLUSH
3.... QUEUE-ONLY
Effect
With this statement you call method meth of automation object ole. The automation-objectmust be created with the special statement CREATEOBJECT for automation-objects. The name of the method has to be specified in a character-like data object meth.
The return value of the external method meth can be stored in a data object rc. This dataobject expects, according to the called method, a character-like data type of length 8 or a data type of type ole2_object from thetype groupOLE2 to be able to accept the addressed object.
Addition 1
... EXPORTING p1 = f1 p2 = f2 ...
Effect
With the addition EXPORTING, you can assign actual parameters f1 f2 ... to the input parametersp1 p2 ... of the automation method. The data type of the data objects f1 f2 ... depends on the requirements of the automation method.
Addition 2
... NO FLUSH
Addition 3
... QUEUE-ONLY
Effect
The additions NO FLUSH and QUEUE-ONLY are described in the statement CREATE OBJECT.
System Fields
| sy-subrc | Relevance |
| 0 | Successful processing of the method meth. |
| 1 | Communication Error to SAP GUI. |
| 2 | Error when calling method meth. |
| 3 | Error when setting a property. |
| 4 | Error when reading a property. |
Example
Depending on the selection on the selection screen, you can open the Excel file Table.xls in directory C:\temp, start the applicationWord and then close both applications again by using this source text. The used automation methods are listed in the following table.
| Application | Method | Parameter | Function |
| Excel | Open | File Name and Path | Open |
| Excel | Quit | - | Exit |
| Word | AppShow | - | Start |
| Word | AppClose | - | Exit |
TABLES sscrfields.
DATA: excel TYPE ole2_object,
word TYPE ole2_object,
book TYPE ole2_object,
rc TYPE c LENGTH 8.
SELECTION-SCREEN:
BEGIN OF SCREEN 100 AS WINDOW TITLE title,
BEGIN OF LINE,
PUSHBUTTON 2(12) button_1
USER-COMMAND word_start,
PUSHBUTTON 20(12) button_2
USER-COMMAND excel_start,
END OF LINE,
BEGIN OF LINE,
PUSHBUTTON 2(12) button_3
USER-COMMAND word_stop,
PUSHBUTTON 20(12) button_4
USER-COMMAND excel_stop,
END OF LINE,
END OF SCREEN 100.
START-OF-SELECTION.
button_1 = 'Start Word'.
button_2 = 'Start Excel'.
button_3 = 'Stop Word'.
button_4 = 'Stop Excel'.
CALL SELECTION-SCREEN 100 STARTING AT 10 10.
AT SELECTION-SCREEN.
CASE sscrfields-ucomm.
WHEN 'WORD_START'.
CHECK word-handle <> -1.
CHECK word-header = space.
CREATE OBJECT word 'Word.Basic'.
CALL METHOD OF word 'AppShow'.
WHEN 'EXCEL_START'.
CHECK excel-handle = 0.
CHECK excel-header = space.
CREATE OBJECT excel 'Excel.Application'.
SET PROPERTY OF excel 'Visible' = 1.
GET PROPERTY OF excel 'Workbooks' = book.
CALL METHOD OF book 'Open' = rc
EXPORTING #1 = 'C:\temp\Table.xls'.
WHEN 'WORD_STOP'.
CALL METHOD OF word 'AppClose'.
FREE OBJECT word.
CLEAR: word-handle, word-header.
WHEN 'EXCEL_STOP'.
CALL METHOD OF excel 'Quit'.
FREE OBJECT excel.
CLEAR: excel-handle, excel-header.
WHEN OTHERS.
LEAVE PROGRAM.
ENDCASE.
SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up rdisp/max_wprun_time - Maximum work process run time
This documentation is copyright by SAP AG.
Length: 8318 Date: 20120518 Time: 201327 triton ( 187 ms )






