-
Notifications
You must be signed in to change notification settings - Fork 0
/
abapcall_method_ole2.html
248 lines (246 loc) · 11.3 KB
/
abapcall_method_ole2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="EN">
<!-- ABAPCALL_METHOD_OLE2 -->
<!-- Mirrored from help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abapcall_method_ole2.htm by HTTrack Website Copier/3.x [XR&CO'2014], Thu, 20 Jan 2022 17:47:30 GMT -->
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="author" content="SAP">
<meta name="description" content="CALL METHOD - OLE">
<meta name="keywords" content="ABAP, CALL METHOD OF - OLE">
<title>
CALL METHOD - OLE - ABAP Keyword Documentation
</title>
<link rel="icon" href="ABAPIcon.ico" type="image/ico">
<link rel="shortcut icon" href="ABAPIcon.ico">
<LINK rel="stylesheet" href="abap_docu.css" type="text/css">
<script type="text/JavaScript">
function call_link(linked_file)
{
if(parent.frames.length>0){
parent.window.frames["basefrm"].window.location = linked_file;
parent.window.frames["treeframe"].window.location = "abap_docu_tree92bd.html?file=" + linked_file;}
else {
window.location = linked_file;}
}
function urlToClipboard(id){
try{ var loc = top.location.href;}
catch(e){ alert( "URL cannnot be determined" ); return; }
var field = document.getElementById(id);
field.focus();
if ( loc.search( ".htm" ) == -1 && loc.search( ".HTM" ) == -1 ){ loc = loc + "index.htm"; }
if ( loc.search( "index.html" ) != -1
|| loc.search( "INDEX-2.html" ) != -1 ){
var off = loc.search( "file=" );
if ( off == -1 ){
field.value = loc + "?file=abapcall_method_ole2.htm"; }
else {
field.value = loc.substring( 0, off ) + "file=abapcall_method_ole2.htm";
}
}
else {
field.value = loc; }
field.setSelectionRange(0, field.value.length);
var r = confirm( "Copy URL to clipboard?\n\n" + field.value + "\n\nCopy to clipboard does not work in all browsers." );
if (r == true) {
try{
document.execCommand("copy");
}
catch(e){ alert( "URL could not be copied to clipboard" ); }
}
window.scrollTo(0,0);
}
</script>
</head>
<body>
<div class="all">
<p class="copyright">SAP NetWeaver AS ABAP Release 751, ©Copyright 2017 SAP AG. All rights reserved.
<input type="button" value="URL" style="font-size:8px; width:26px; height:16px; padding:0"
onclick="urlToClipboard('url')" title="Copy URL to Clipboard" >
</p>
<span class="path">
<a href="javascript:call_link('abenabap.html')" class="blue">ABAP - Keyword Documentation</a> →
<a href="javascript:call_link('abenabap_reference.html')" class="blue">ABAP - Reference</a> →
<a href="javascript:call_link('abenabap_data_communication.html')" class="blue">Data Interfaces and Communication Interfaces</a> →
<a href="javascript:call_link('abenole2.html')" class="blue">ABAP and OLE</a> →
</span>
<A NAME="@@CALL METHOD OF - OLE@@!ABAP_STATEMENT!@@"></A>
<p><span class="h1">
CALL METHOD - OLE <br><br>
</span></p>
<P>
<a href="javascript:call_link('abapcall_method_of_ole_shortref.html')" class="blue">Quick Reference</a> <br><br>
</P>
<p><span class="h2">
<span class="bold">Syntax</span>
</span></p>
<P>
<span class="qtext"> CALL METHOD OF ole meth <i class=bn>[</i>= rc<i class=bn>]</i> <br>
<i class=bn>[</i>EXPORTING p1 = f1 p2 = f2 ...<i class=bn>]</i> <br>
<i class=bn>[</i>NO FLUSH<i class=bn>]</i> <i class=bn>[</i>QUEUE-ONLY<i class=bn>]</i>.</span> <br><br>
</P>
<p><span class="h3">
Extras:
</span></p>
<P>
<A HREF="#!ABAP_ADDITION_1@1@" class="blue"> 1.<span class="qtext">... EXPORTING p1 = f1 p2 = f2 ...</span> </A> <br>
<br><A HREF="#!ABAP_ADDITION_2@2@" class="blue"> 2.<span class="qtext">... NO FLUSH</span> </A> <br><br><A HREF="#!ABAP_ADDITION_3@3@" class="blue"> 3.<span class="qtext">... QUEUE-ONLY</span> </A> <br><br>
</P>
<p><span class="h4">
Effect
</span></p>
<P>
This statement calls the method <span class="qtext">meth</span> of the automation object <span class="qtext">ole</span>.
The automation object must have been created using the special statement <a href="javascript:call_link('abapcreate_object_ole2.html')" class="blue">
<span class="qtext">CREATE OBJECT</span></a> for automation objects. The name of the method has to be specified in a character-like data object <span class="qtext">meth</span>.
</P>
<P>
The return value of the external method <span class="qtext">meth</span> can be stored in a data object
<span class="qtext">rc</span>. This data object expects, in accordance with the called method, a character-like data type of length 8 or a data type of type <span class="qtext">ole2_object</span> from the
<a href="javascript:call_link('abentype_group_1_glosry.html')" class="grey" title="Glossary Entry">type group</a> <span class="lnkgrey">OLE2</span> to be able to accept the addressed object. <br><br>
</P>
<A NAME="@@EXPORTING@@CALL METHOD OF - OLE@@"></A>
<p><span class="h3">
<A NAME="!ABAP_ADDITION_1@1@"></A> <span class="bold">Addition 1</span>
</span></p>
<P>
<span class="qtext">... EXPORTING p1 = f1 p2 = f2 ...</span> <br><!-- /A -->
</P>
<p><span class="h4">
Effect
</span></p>
<P>
The addition <span class="qtext">EXPORTING</span> can be used to assign actual parameters <span class="qtext">f1
f2 ...</span> to the input parameters <span class="qtext">p1 p2 ...</span> of the automation method.
The data type of the data objects <span class="qtext">f1 f2 ...</span> depends on the requirements of the automation method. <br><br>
</P>
<A NAME="@@NO FLUSH@@CALL METHOD OF - OLE@@"></A>
<A NAME="@@QUEUE-ONLY@@CALL METHOD OF - OLE@@"></A>
<p><span class="h3">
<A NAME="!ABAP_ADDITION_2@2@"></A> <span class="bold">Addition 2</span>
</span></p>
<P>
<span class="qtext">... NO FLUSH</span> <br><!-- /A -->
</P>
<p><span class="h3">
<A NAME="!ABAP_ADDITION_3@3@"></A> <span class="bold">Addition 3</span>
</span></p>
<P>
<span class="qtext">... QUEUE-ONLY</span> <br><!-- /A -->
</P>
<p><span class="h4">
Effect
</span></p>
<P>
The additions <span class="qtext">NO FLUSH</span> and <span class="qtext">QUEUE-ONLY</span> are described
in the statement <a href="javascript:call_link('abapcreate_object_ole2.html')" class="blue"><span class="qtext">CREATE OBJECT</span></a>. <br><br>
</P>
<P>
<span class="bold">System Fields</span>
</P>
<table border>
<tr>
<td><span class="qtext">sy-subrc</span></td>
<td><span class="bold">Meaning</span></td>
</tr>
<tr>
<td>0</td>
<td>Method <span class="qtext">meth</span> executed successfully.</td>
</tr>
<tr>
<td>1</td>
<td>Error in communication with SAP GUI.</td>
</tr>
<tr>
<td>2</td>
<td>Error when calling the method <span class="qtext">meth</span>.</td>
</tr>
<tr>
<td>3</td>
<td>Error when setting an attribute.</td>
</tr>
<tr>
<td>4</td>
<td>Error when reading an attribute.</td>
</tr>
</table><br>
<p><span class="h4">
Example
</span></p>
<P>
Depending on the selection on the <a href="javascript:call_link('abenselection_screen_glosry.html')" class="grey" title="Glossary Entry">
selection screen</a>, this source code can be used to open the Excel file Table.xls in directory C:\temp,
start the application Word, and then close both applications again. The automation methods used are listed in the following table. <br><br>
</P>
<table border>
<tr>
<td><span class="bold">Application</span></td>
<td><span class="bold">Method</span></td>
<td><span class="bold">Parameter</span></td>
<td><span class="bold">Function</span></td>
</tr>
<tr>
<td>Excel</td>
<td>Open</td>
<td>File name and path</td>
<td>Open</td>
</tr>
<tr>
<td>Excel</td>
<td>Quit</td>
<td>-</td>
<td>Exit</td>
</tr>
<tr>
<td>Word</td>
<td>AppShow</td>
<td>-</td>
<td>Start</td>
</tr>
<tr>
<td>Word</td>
<td>AppClose</td>
<td>-</td>
<td>Exit</td>
</tr>
</table><br>
<p class="qtextml1">
<span class="qtext">
TABLES sscrfields. <br> <br>DATA: excel TYPE ole2_object, <br> word TYPE ole2_object, <br>
book TYPE ole2_object, <br> rc TYPE c LENGTH 8. <br>
<br>SELECTION-SCREEN: <br> BEGIN OF SCREEN 100 AS WINDOW TITLE title, <br> BEGIN OF LINE, <br>
PUSHBUTTON 2(12) button_1 <br>
USER-COMMAND word_start, <br>
PUSHBUTTON 20(12) button_2 <br>
USER-COMMAND excel_start, <br>
END OF LINE, <br> BEGIN OF LINE, <br> PUSHBUTTON 2(12) button_3 <br>
USER-COMMAND word_stop, <br>
PUSHBUTTON 20(12) button_4 <br>
USER-COMMAND excel_stop, <br>
END OF LINE, <br> END OF SCREEN 100. <br> <br>START-OF-SELECTION. <br>
button_1 = 'Start Word'. <br> button_2 = 'Start Excel'. <br> button_3 = 'Stop Word'. <br>
button_4 = 'Stop Excel'. <br> CALL SELECTION-SCREEN 100 STARTING AT 10 10. <br>
<br>AT SELECTION-SCREEN. <br> CASE sscrfields-ucomm. <br> WHEN 'WORD_START'. <br>
CHECK word-handle <> -1. <br> CHECK word-header = space. <br>
CREATE OBJECT word 'Word.Basic'. <br> CALL METHOD OF word 'AppShow'. <br>
WHEN 'EXCEL_START'. <br> CHECK excel-handle = 0. <br>
CHECK excel-header = space. <br> CREATE OBJECT excel 'Excel.Application'. <br>
SET PROPERTY OF excel 'Visible' = 1. <br> GET PROPERTY OF excel 'Workbooks' = book. <br>
CALL METHOD OF book 'Open' = rc <br> EXPORTING #1 = 'C:\temp\Table.xls'. <br>
WHEN 'WORD_STOP'. <br> CALL METHOD OF word 'AppClose'. <br>
FREE OBJECT word. <br> CLEAR: word-handle, word-header. <br>
WHEN 'EXCEL_STOP'. <br> CALL METHOD OF excel 'Quit'. <br>
FREE OBJECT excel. <br> CLEAR: excel-handle, excel-header. <br>
WHEN OTHERS. <br> LEAVE PROGRAM. <br> ENDCASE.
</span>
</p>
<br>
<br>
<br>
<br>
</DIV>
<fieldset style="opacity:0">
<input id="url" type="text" />
</fieldset>
</BODY>
<!-- Mirrored from help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abapcall_method_ole2.htm by HTTrack Website Copier/3.x [XR&CO'2014], Thu, 20 Jan 2022 17:47:30 GMT -->
</html>