Skip to Content
 

The SAP Enterprise Connector is a development tool that provides help classes and RFC function module method calls for Java applications. These method calls and help classes are called Java Proxy.

The Java Proxy hides native SAP Java Connector (JCo) calls. This architecture guarantees type-secure data access and increases client application stability.

 

Here’s a small example that explains what a Java proxy (or any other proxy or stub) is.

Consider a classroom where a student XYZ remains absent. However, his classmate inside says “Present” on XYZ’s roll-call. The teacher does not notice and XYZ is marked present. This is because it “appeared” to the teacher that XYZ was present in the class.This is what we call “Proxy Attendance”.

Similarly, consider two machines connected over the internet. The remote machine has a function XYZ( ) with its proper definition. The function XYZ( ) is similar to our student XYZ( ).

The local machine where we need to call the function XYZ( ) must store the proxy class for the function XYZ( ). This proxy is similar to our student XYZ’s classmate who gives the attendance.

The Client program on the local machine thinks that the function definitions are present on the local machine itself and are also executing on the local machine. However, in reality they are present and are executing on the remote machine. This client program is similar to our class-teacher.

  

Now to using the SAP Enterprise Connector to generate the Java Proxies for any BAPI so that the BAPI can be comfortably called from a simple Java program.

We will invoke BAPI_FLIGHT_GETLIST  in our example.

  1. Create a Java Project.
  2. Create a Package in the project say com.tcs.poc.
  3. Start SAP Enterprise Connector by selecting  File -> New -> Other.
  4. Expand SAP Connectivity and select SAP Enterprise Connector.

         

 

    5.   Select an appropriate source folder.

          Select the package that you have already created viz. com.tcs.poc.

          Enter a suitable name for the proxy class say Java_Jco.

          ( _PortType will be automatically appended to the class name i.e. the proxy  

          class name is Java_Jco_PortType.)  

        

        

 

    6.   Enter the logon details for the ECC System.

          image

 

     7. If you have got the logon details perfect, the next screen will ask you to 

         select the RFC modules. 

In the Function Name text box enter BAPI_FLIGHT_GETLIST or BAPI_FLIGHT_* and click on search to get a list of BAPIS.

Select the BAPI_FLIGHT_GETLIST and click on Finish to see your proxy classes generate.

        

 

 

Now that our Proxy classes are ready, we can create their instances in our Java class and execute the BAPI.

 

But before we actually execute the BAPI we need to include some libraries in the Build Path of the project.  

            These libraries are found in SAP\IDE\IDE70\eclipse\plugins

They are as follows:

 Library jar                  Found in folder

1. sapjco.jar     \SAP\IDE\IDE70\eclipse\plugins\com.sap.mw.jco_2.0.0\lib

2. SAPmdi.jar   \SAP\IDE\IDE70\eclipse\plugins\com.sap.mdi_2.0.0\lib

3. aii_rt_proxy  \SAP\IDE\IDE70\eclipse\plugins\com.sap.ide.jcb.core_2.0.0\lib

4. aii_util_misc    \SAP\IDE\IDE70eclipse\plugins\com.sap.ide.jcb.core_2.0.0\lib 

 

Once these libraries are included in the build path, we proceed with the actual java class, a sample of which is provided below.

 

To report this post you need to login first.

4 Comments

You must be Logged on to comment or reply to a post.

  1. Ramakrishna Venkat
    Hi Mayuresh Kanvinde,

    Good Blog, but hard coding system details like client, username, password in the code theoretically ok. In customer projects it is not a good practice to hardcode system details.

    Regards,
    RK

    (0) 
    1. Mayuresh Kanvinde Post author
      Hi Ramakrishna,
      Thank you very much.
      Regarding the hardcoded system details, I would say that this code is just an example to explain how the JCO can been established from Java and how SAP Enterprise connector can be used.
      When actually dealing with client projects, I completely agree with your view of not hardcogding the system details.
      (0) 
    1. Mayuresh Kanvinde Post author
      Hi Sushil,
      Try to execute the BAPI from SAP and see if you have authorizations for the user & password you are using. Also, check if data exists for the airline. Getting the data in the Return table might help in understanding the problem.
      Regards,
      (0) 

Leave a Reply