Home » Developer & Programmer » Forms » Calling a SAP RFC from an Oracle Form - using OLE?
Calling a SAP RFC from an Oracle Form - using OLE? [message #387414] Thu, 19 February 2009 02:56 Go to next message
browd@whl.co.uk
Messages: 5
Registered: February 2009
Location: UK
Junior Member
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... Confused

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 Sad

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

Re: Calling a SAP RFC from an Oracle Form - using OLE? [message #398601 is a reply to message #387414] Thu, 16 April 2009 21:06 Go to previous messageGo to next message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
Have you solved your problem?

David
Re: Calling a SAP RFC from an Oracle Form - using OLE? [message #398633 is a reply to message #387414] Fri, 17 April 2009 00:40 Go to previous messageGo to next message
browd@whl.co.uk
Messages: 5
Registered: February 2009
Location: UK
Junior Member
Yes we did get a solution to this.

We moved away from the OLE route and followed these instructions instead:

http://www.oracle.com/technology/products/forms/htdocs/10gr2/howto/webservicefromforms/ws_10_1_3_from_forms.html#t1

That is an article titled:

SOA for Forms and 4GL Developers: Calling a Web service from Oracle Forms 10.1.2


It is a little convoluted but works.

Basically you use JDeveloper to create a WEB Proxy of a WSDL file. It creates a JAVA Wrapper which can then be imported into a form.

This means in the end you have something like:

1) The user presses a button on the form
2) The form calls the PL/SQL (for the improted JAVA)
3) The PL/SQL calls the JAVA object
4) The JAVA object calls the Web Service

It took a bit of fiddling to setup (a Service Reuqest)and then to get it to work on our UNIX OAS (another Service Request) but it does work and we will be implementing it as part of our current project.

Hope that helps anyone going down a similar route.

Cheers
Dan
Re: Calling a SAP RFC from an Oracle Form - using OLE? [message #398646 is a reply to message #398633] Fri, 17 April 2009 01:17 Go to previous message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
Thank you very much for your response.

David
Previous Topic: Controlling user access to menus
Next Topic: Validation problem
Goto Forum:
  


Current Time: Sat Dec 03 22:15:57 CST 2016

Total time taken to generate the page: 0.07602 seconds