Skip to Main Content

Oracle Forms

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How do I call a SAP RFC from an Oracle Form using webutils CLIENT_OLE2?

dansterFeb 19 2009
Hi guys,

Your help on this problem would be greatly appreciated.

We have an older forms 6i application which we are currently updating to 10g (which is a pain itself... but that's a different story.) which currently uses unssupported c++ routines to connect to the SAP system, we want to do away with this c++.

What I have so far is the following test code:

PROCEDURE cmd_summary
IS
o_sap_log client_ole2.obj_type;
o_sap_conn client_ole2.obj_type;
o_sap_rfcc client_ole2.obj_type;
-- o_sap_rfcx client_ole2.obj_type;
-- o_sap_rfc client_ole2.obj_type;

v_args ole2.list_type;
v_logon BOOLEAN := FALSE;
BEGIN
:block3.txt_result := 'TEST Started!';
--create logon control object
o_sap_log := client_ole2.create_obj ('SAP.logoncontrol.1');
--create the function object
o_sap_rfcc := client_ole2.create_obj ('SAP.Functions');
--create a new connection object
o_sap_conn := client_ole2.invoke_obj (o_sap_log, 'NewConnection');
--set the connection properties
client_ole2.set_property (o_sap_conn, 'System', caps$get_sys_param ('SAP_DST'));
client_ole2.set_property (o_sap_conn, 'MessageServer', caps$get_sys_param ('SAP_HST'));
client_ole2.set_property (o_sap_conn, 'GroupName', 'DEVELOP');
client_ole2.set_property (o_sap_conn, 'client', caps$get_sys_param ('SAP_CLT'));
client_ole2.set_property (o_sap_conn, 'SystemNumber', caps$get_sys_param ('SAP_SYN'));
client_ole2.set_property (o_sap_conn, 'User', caps$get_sys_param ('SAP_USR'));
client_ole2.set_property (o_sap_conn, 'Password', caps$get_sys_param ('SAP_PWD'));
client_ole2.set_property (o_sap_conn, 'language', caps$get_sys_param ('SAP_LNG'));

--set up the logon arguements
v_args := client_ole2.create_arglist;
client_ole2.add_arg (v_args, 1);
client_ole2.add_arg (v_args, TRUE);
--run the logon function
v_logon := client_ole2.get_bool_property (o_sap_conn, 'logon', v_args);
client_ole2.destroy_arglist (v_args);

IF v_logon
THEN
:block3.txt_result := :block3.txt_result || CHR (10) || 'LOGON Worked!!';
ELSE
:block3.txt_result := :block3.txt_result || CHR (10) || 'LOGON Failed!!';
END IF;

:block3.txt_result := :block3.txt_result || CHR (10) || 'TEST Ended!';
EXCEPTION
WHEN OTHERS
THEN
:block3.txt_result := :block3.txt_result || CHR (10) || SQLERRM (SQLCODE);
END cmd_summary;

NOTE: the get_sys_param functionis returning text from a table.

This seems to work okay, the logon command returning a TRUE. All good so far.

However, when I try to then use this connection for anything then I stumble and fall!

I've seen an example in VB where the SAP RFC object is "assigned" the connection object by simply stating:

Set oSAPrfc.Connection = oSAPconn

Where oSAPconn is setup in a similar way to my o_Sap_conn in the above example.

I have tried using the CLIENT_OLE2.SET_PROPERTY procedures but I don't think that's quite right.

I've tried using invoke, to try and "run" the method like:

v_args := CLIENT_OLE2.CREATE_ARGLIST;
client_ole2.add_arg_obj(v_args,o_sap_conn);
client_ole2.invoke(o_sap_rfcc,'Connection',v_args);
client_ole2.destroy_arglist(v_args);

but it fails.

I have also tried using the actual Connection function directly:

SAP_ISAPFUNCTIONS.connection(o_sap_rfcc, o_sap_conn);

But that just causes the Forms Server to crash... :?

Has anyone connected to SAP via Forms? I noticed one post on this forum which an example of some code using a SAPBAPI control but not WEBUTIL (Which I think I'd need to use because we are running 10g)

As a side note we are also looking into SAP Adapter as a possible "other" route but this too is getting very complicated... And I can't see a way of connecting a form to the Adpater anyway :(

Any advice would be very much appreciated.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 19 2009
Added on Feb 19 2009
0 comments
740 views