WUO-705 - OleFunctions.invoke_ret_obj()

WUO-705 - OleFunctions.invoke_ret_obj()

WUO-705 - OleFunctions.invoke_ret_obj()

Titleimage

Posted by Patrick Hamou on 2016:04:20 02:21:07

Applies to

Oracle Forms - Version 10.1.2 and later
Information in this document applies to any platform.
Checked for relevance : 03-Jan-2011
Checked for relevance : 03-Oct-2012

Symptoms

When attempting to run Forms with webutil that opens a pdf or any document,
the following exception occurs:

WUO-705 [OleFunctions.invoke_ret_obj()] Unable to invoke Method: Navigate; Exception
com.jacob.com.ComFailException: VariantChangeType failed

However the document still opens in a new browser window.

Steps to Reproduce:
-----------------------

1. Create a simple form with a text field txt_ABC and button.

2. In the when-button-pressed trigger, code the following: 

declare
-- Handle of the Application object(s) 
obtApplication CLIENT_OLE2.OBJ_TYPE; 
obtDoc CLIENT_OLE2.OBJ_TYPE;

-- Handle of the OLE argument list 
obtArgs CLIENT_OLE2.OBJ_TYPE; 

Begin
:txt_ABC := 'BEGIN'; pause;
obtApplication := client_ole2.create_obj('InternetExplorer.Application'); 
Client_Ole2.Set_Property(obtApplication,'Visible',1);

-- Tell the OLE object to load the file 
:txt_ABC := 'LOAD'; pause;
obtArgs := client_ole2.create_arglist; 
Client_Ole2.add_arg(obtArgs, 'd:\temp\dept.pdf'); -- Some existing PDF file name here
obtDoc := Client_Ole2.invoke_obj(obtApplication, 'Navigate', obtArgs); 
Client_Ole2.destroy_arglist(obtArgs); 

-- Release all the objects 
:txt_ABC := 'RELEASE'; pause;
Client_Ole2.release_obj(obtDoc); 
Client_Ole2.release_obj(obtApplication); 
:txt_ABC := 'END'; pause;

exception
when others then
:txt_ABC := 'EXCEPTION: Unable to view document. Error: '|| substr(sqlerrm, 100); pause;
Client_Ole2.release_obj(obtDoc); 
Client_Ole2.release_obj(obtApplication); 
End;

3. Compile and run the Form.

4. Click the Button to open the document.

5. Receive WUO-714 [OleFunctions.setExceptionValues()] Unable to get the last OLE Error details;

Exception
null
WUO-705 [OleFunctions.invoke_ret_obj()] Unable to invoke Method: Navigate; Exception
com.jacob.com.ComFailException: VariantChangeType failed

6. The pdf document opens in a new browser window.

Changes

Migrating from 9i to 10g with webutil or upgrading webutil from 1.0.5 to 1.0.6 or 10.1.2.2 or 10.1.2.3

or

New code development invoking some method.

Cause

The function Client_Ole2.invoke_obj should only be used when the method invoked returns an object. The types of variables used and returned by the methods and properties of an OLE Application are listed in its Object Model, and it must be respected.

The exception here turns up to be a warning and seemed to occur silently in version 1.0.5.

Solution

The solution is to replace the Client_Ole2.invoke_obj function call with the Client_Ole2.invoke procedure call .

This is because in this case the method 'Navigate' of Internet Explorer's Object Model does not return anything. One should not be using invoke_obj, that by design expects an object being returned by the method called, when nothing is in fact returned by that method.

There are different invoke_xxx calls to allow for the xxx type of variable returned by the method called. This is similar to the different Get_xxx_property calls, xxx corresponding to the type of variable the particular property returns. For more information on these program units please consult the Forms On-Line help for the OLE2 package as Client_OLE2 is designed to work as closely to it as possible.

In the sample code provided in this note, you can change the following:

1. Comment the code that has Client_Ole2.invoke_obj function call

--obtDoc := Client_Ole2.invoke_obj(obtApplication, 'Navigate', obtArgs);

2. Replace it with Client_Ole2.invoke procedure call:

Client_Ole2.invoke(obtApplication, 'Navigate', obtArgs);

3. Recompile and test the form again, there should be no error as the code is now respecting the Object Model of the application used.

Posted by Patrick Hamou on 2016:04:20 02:21:07

Return to Blog