Frequently Asked Questions


Table of Contents

  1. How to download the plugin ?

  2. How to install the plugin ?

  3. Where can I find sample code ?

  4. Why doesn't the plugin work ?

  5. What if i don't want to use the plugin (Non eclipse users)?

  6. What is SAP-JCO ?

  7. How to install SAP-JCO ?

  8. Where is the API Documentation?

  9. Concepts involved!

  10. Complete scenario with code( BAPI_COMPANYCODE_GETDETAIL ) 

  11. Discussion Forums !

  12. Source code

  13. Tips on JCO, Java-SAP Integration!

  14. How to report a Bug ?

  15. My Blog


How to download the plugin ?

Here the link to the latest download Download

Back to Top

How to install the plugin ?

Just unzip the sap2java.1.X.X.jar in the <eclipse_home>\plugins\ directory. The plugins directory will now have com.sap.plugin.Sid1.X.X directory in it.  Copy you jco.jar/sapjco.jar file into this directory In that directory you will find test.jar which is needed for the plugin to run. Refer to the Readme file in that directory for more information.

Back to Top

Where can I find sample code ?

Here is a sample scenario where a function module makes an outbound call --

Goto SE37 and create a Function module Z_TEST_SID. Make it RFC Enabled (  You should see it in Admin tab ). Create the following interfaces

Import params
RFC_PARAM4 SY-UNAME

Export params
RFC_PARAM3 SY-LISEL
RFC_PARAM5 BAPIRETURN

Table
ZIT_LEG_CLASS  ZIT_CLS
ZIT_DET    ZIT_OUT


The R3 function module code will be --

call function 'Z_TEST_SID' destination 'PROGID' 
exporting
    rfc_param4 = sy-uname 
importing 
    rfc_param3 = rfc_param3 
    rfc_param5 = bapireturn 
tables
    zit_leg_class = zit_cls 
    zit_det = zit_out 
exceptions 

   communication_failure = 1 
    system_failure = 2. 

 

Java CustomListener class will be --

package com.sap.bapi.util;

import com.sap.bapi.listener.SAPListener;
import com.sap.mw.jco.JCO;
import com.sap.generated.*;

public class CustomListener extends SAPListener
{

public CustomListener(String host, String progId , String gateway , String clientID, String userName, String passWord)
{
super( host, progId, gateway , clientID, _  userName,passWord);
}

public static void main( String a[] )
{
CustomListener s = new CustomListener("sapdev",_ "ProgID", "3300", "130", "username", "pass");
        s.setPackageName("com.sap.generated");
}
 

// handleRequest overrides superclass function

public void handleRequest(JCO.Function function) 
{
// The first call should be to the super class function
    super.handleRequest(function); 

//Get the input Objects
    Object input[] = super.getInput(); 

    InputZ_test_sid in = (InputZ_test_sid) input[0];
    if ( input[0] != null )
System.out.println ( "Input is >> " + in.getRFC_PARAM4() );

//Get the table Objects 
    Object tables[] = super.getTables();

    if ( tables != null ) {
    // Do processing.


    //Set the table Objects.
    super.setTables(s);
}

//Set the Output Structures
    OutputZ_test_sid o = new OutputZ_test_sid();
    o.setRFC_PARAM3("success");
    setOutput(o);

}


}//end CustomListener
 

Dont bother about the ZTable definitions .. The code tells you how to use the generated java objects to handle outbound calls from R3.
 

Back to Top

Why doesn't the plugin work ?

There could be a number of reasons 

Back to Top

What if i don't want to use the plugin (Non eclipse users)?

No problems. If you don't want to use the plugin then you should do the following 

        Here is how you can call SAP2Java to generate java-objects-

        public static void main(String args[]){

        String host="r3dev";
       String client="110";
       String uname="username";
       String pass="passwd";
       String sysNo="00";
       String lang="EN";
       String basePath="/test";
       String packName="com.sap.generated";;

        try {
        com.sap.bapi.mapper.SAP2Java s = new com.sap.bapi.mapper.SAP2Java(host,client,uname,pass,sysNo,lang);
           com.sap.bapi.io.Filer.setBasePath(basePath);
           com.sap.bapi.io.Filer.setPackageName(packName);
           s.execute( fileName );

        }catch ( com.sap.bapi.mapper.exception.BAPIException ){

        }

        
          }

Back to Top

What is SAP-JCO ?

The SAP Java Connector (SAP JCo) is a toolkit that allows a Java application to communicate with any SAP system. It combines an easy to use API with unprecedented flexibility and performance. The package supports both, Java to SAP System as well as SAP System to Java calls.

Back to Top

How to install SAP-JCO ?

You can obtain the jCO.jar file from the  SAP site( you will need a user id /password ).

Windows NT, Windows 2000

Unzip the file jco-ntintel-1.1.02.zip into an arbitrary directory {jco-install-path}.
If you already have an older librfc32.dll in the c:\WINNT\system32 directory, please replace it with the one that comes with JCo.
Finally, add {jco-install-path}\jCO.jar to your CLASSPATH environment variable.

Note: If you already had an older version of JCo installed on your system, please make sure that you delete the libraries jRFC11.dll and jRFC12.dll from c:\WINNT\system32. In addition, make sure that CLASSPATH does not contain the path to the old JCo installation anymore.

Back to Top

Where is the API Documentation?

I am still working on it. However here is the link to the Partial Documentation

Back to Top

Concepts Involved!

The data type mapping between ABAP and Java is based on the following set -

   ABAP Type    Java Type
 RFCTYPE_CHAR java.lang.String
 RFCTYPE_DATE java.util.Date
 RFCTYPE_BCD java.math.BigDecimal
 RFCTYPE_TIME java.util.Date
 RFCTYPE_BYTE byte []
 RFCTYPE_NUM java.math.BigInteger
 RFCTYPE_FLOAT double
 RFCTYPE_INT int
 RFCTYPE_INT2 short
 RFCTYPE_INT1 byte

The function module meta data information is retrieved using the JCO.ParameterList's methods ( isStructure, isTable etc) . The mapping between the java and sap at runtime is done using the Reflection API

Back to Top

Complete scenario with code( BAPI_COMPANYCODE_GETDETAIL )

This gives an idea of how to use the plugin to generate java objects and how to extend the other sample classes available to make calls to R3 .

Back to Top

Discussion Forums!

Back to Top

Source Code

Download Source

Back to Top

How to report a Bug ?

Send me a mail

Back to Top

Author : Siddhartha Bhattacharya
Revised: Jan 18, 2006 .

SourceForge.net Logo