|Calling a SAP RFC from an Oracle Form - using OLE? [message #387414]
||Thu, 19 February 2009 02:56
Registered: February 2009
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:
-- o_sap_rfcx client_ole2.obj_type;
-- o_sap_rfc client_ole2.obj_type;
v_logon BOOLEAN := FALSE;
: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);
:block3.txt_result := :block3.txt_result || CHR (10) || 'LOGON Worked!!';
:block3.txt_result := :block3.txt_result || CHR (10) || 'LOGON Failed!!';
:block3.txt_result := :block3.txt_result || CHR (10) || 'TEST Ended!';
:block3.txt_result := :block3.txt_result || CHR (10) || SQLERRM (SQLCODE);
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;
but it fails.
I have also tried using the actual Connection function directly:
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.
[EDITED by DJM: removed trailing 'tabs' in code]
[Updated on: Thu, 19 February 2009 22:40] by Moderator
Report message to a moderator