Skip to Content
Author's profile photo Sharath M G

Proxy Class to access SAP Functions: JCo and Enterprise Connector

Hello All,

This blog is a compilation of quick steps to develop proxy classes to access the SAP functions(remote-enabled) from non-SAP UI technologies.

[ Inspired by the forum question : http://scn.sap.com/thread/3404002 ]

The steps to be followed are:

1. Install NWDS on your local machine.

     NWDS is available in SDN. For complete list of NWDS versions use the link: https://nwds.sap.com/swdc/downloads/updates/netweaver/nwds/ce/ (It requires an S-User ID. Contact any SAP developer for an S-User ID).

2. Then, create a Java Project.

JcoConnector_1.PNG

3. Complete the Project creation. Right-click on project and choose New->Other. In the window select ” Enterprise Connector “.

JcoConnector_2.PNG

4. Click Next. Then, fill the necessary fields.

JcoConnector_3.PNG

5. Provide the SAP System details and SAP login credentials to access the remote-enabled SAP functions.

JcoConnector_4.PNG

6. On successful login, search for the function to be used by your application i.e. function for which the proxy classes are required.

JcoConnector_5.PNG

7. Finally, the proxy classes are generated.

However, since the JCo library files/apis are not available in the Java project, it results in compile errors for all SAP JCo classes in the project.

The following steps will assist you on add the JCo related jar files to the Java project.

1. Go to the build path of the Java project. Choose, External Jars and navigate to the plugins folder of the NWDS.

2. Look up the plugins for the following jar files:

  • SAPmdi.jar
  • sapjco.jar
  • aii_util_msc.jar
  • aii_proxy_rt.jar

JcoConnector_11.PNG

3. Click on OK. Now, the java project and proxy classes are ready to be used in your application.

All the Best.

Regards,

Sharath

Assigned Tags

      4 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Andriy Klymenko
      Andriy Klymenko

      Hi, All,

      I would like to add my coin to this disscussion because exactly at this moment I'm trying to call that mentioned SAP Rfc module from Java using JCo connector. I've found several similar articles with the same steps dated from the 2007.

      For example I use this one:

      http://help.sap.com/saphelp_nw04/helpdata/en/b6/55e3952a902447847066a0df27b0d6/content.htm

      I'd like to share my current experience in this question.

             I'm not a Java developer and my experience in this language is pretty small and only theoretical. Sometimes ago I've tried myself in Java using Eclipse IDE but now decided to use NWDS assuming it's better inregrated or adapted with a system, I've installed an NWDS and JCo comes with it.

      Of course after implementing all steps I was unable to build a project because of the most common Java error - NoClassDefFoundError when some of a project's classes can not be generated. So, I've tried to add mentioned classes according to the listing:

      " aii_proxy_rt.jar

      aii_util_misc.jar

      SAPmdi.jar

      sapjco.jar "

      Unfortunately, my installed library doesn't have two of them: SAPmdi.jar and aii.proxy.rt.jar. I'm not sure if exactly these classes are present in a current versions of JCO, Instead, I have the following:

      com.sap.mdi_10.0.0.130621115249 -> com.sap.mdi_api.jar

      com.sap.tc.ap_2.0.1.130621115249\comp\FRAMEWORK\DCs\sap.com\tc\ddic\ddicruntime

        - com.sap.mdi.jar

      com.sap.aii.proxy.rt.eci_2.0.0.130621115249 -> tc~aii~proxy_rt_api.jar

      One article suggested to add libraries from the variable SAP_SYSTEM_ADD_LIBS.

      And I continuosly was trying to add different combinations and names from that variable and catching pretty stable result - error NoClassDefFoundError and a lot of warning that JCO class and its types are deprecated. Until, at some moment NWDS crashed and mentioned variable disappeared. It worth saying that my installation has several JCO classes as well. They are:

      com.sap.mw.jco_2.0.0.130621125249 -> sapjco.jar

      com.sap.tc.ap_2.0.1.130621115249\comp\FRAMEWORK\DCs\sap.com\tc\ddic\ddicruntime -> jco.jar

      com.sap.tc.ap_2.0.1.130621115249\comp\ENGINEAPI\DCs\sap.com\com.sap.mw.jco

        sap.com~_com.sap.mw.jco~default.jar

      After I had lost a variable I added JCO class from  the com.sap.mw.jco_2.0.0.130621125249 and, was pleasantly suprised - code has been executed.

      Now I'm fighting with the next issue - I need to specify a SAP router string when calling to the RFC function and JCO constructor doesn't have a corresponding parameter. Ones wrote that it's impossible to pass a router string but I don't believe in it. If anyone have an experience to share I would appreciate it.

      And don't forget about FM releasing in FM builder through the main menu in order to generate a Java proxy.

      Author's profile photo Sharath M G
      Sharath M G
      Blog Post Author

      Hello Andriy,

      Thank you for the feedback.

      At many occasions, some solutions which seem logically straightforward are faced with dead-end points. I have had similar experiences.

      Many times the devil is in the smallest of the detail, which we tend to ignore with the confidence of prior knowledge and later feel stuck in a quick sand.

      My effort was to provide the steps in the simplest of form which will be helpful in such situations.

      Thank you.

      Regards,

      Sharath

      Author's profile photo Andriy Klymenko
      Andriy Klymenko

      Yes, sure.

      Just wanted to share my experience. Now I'm able to compile it. I use NWDS 7.1 SP17, run it under Windows XP. SAP_SYSTEM_LIBS variable continuously appear and dissapear - can't cope with this issue so can't rely on it. For compilation I use JCo library under ECLIPSE_HOME\plugins variable. And others libraries added both from the SAP_SYSTEM_LIBS\comp\FRAMEWORK and again from ECLIPSE_HOME. When connection to SAP_SYSTEM_LIBS restores I have an error regarding duplicate entries but at least it works. ) 

      Author's profile photo Sharath M G
      Sharath M G
      Blog Post Author

      Good to hear that your issue is resolved.

      Regards,

      Sharath