sap interface, how to learn sap, sap connection, process sap, sap process, sap application integration

Talk to SAP with JCo

SAP Interfacing with VBA. In this blog you will get some informations about :
Best Information For Talk to SAP with JCo | Talk to SAP with JCo Articles

To create a Java-based Web Service that relies on SAP data and functionality we will need a mechanism for communicating with SAP. That mechanism is JCO. This article is not a complete tutorial on JCO. More information about JCo is available at and downloading Unzip this file and view the file JCOTutorial.pdf in the docs directory.

In this article we will demonstrate how to use JCO to do the following:1. Connect with SAP2. Create a respository for BAPI metadata3. Set BAPI input parameters4. Execute the BAPI5. Extract BAPI output parameters6. Disconnect from SAP

Connect to SAPThe JCO.createClient() method uses SAP connection information to create a JCO.client object. Then the connect() attempts to login to R/3 using a specific userid and a password. If successful, the JCO.client object will represent an SAP connection.JCO.Client client = JCO.createClient( look at docs for input parameters ); client.connect();

BAPI Repository and metadataA BAPI Repository is a place to store BAPI metadata. This is information about the BAPI itself including all input, output, and in/out parameter names, data types, and lengths.JCO.Repository repository = new JCO.Repository("Gamma", client);

We now ask the repository for metadata about a specific BAPI. Here we are working with the BAPI_MATERIAL_GETLIST. Please review SAP documentation for more information about this BAPI. This BAPI actually uses 10 different parameters. By asking the repository for BAPI metadata, we do not have to write the code to set up these 10 parameters. Also, we are returned a JCO.Function object that contains BAPI metadata.

JCO.Function function = repository.getFunctionTemplate("BAPI_MATERIAL_GETLIST").getFunction();

Setting input parametersBefore we execute this BAPI, we must set some input parameters. We will set three fields within the MATNRSELECTION table parameter, MATNR_LOW – this will contain a wildcard pattern to search for materials by name. For example, vac* will return all materials starting with the letters vac.SIGN – set to I to include materials.

OPTION – set to CP to indicate that MATNR_LOW contains a pattern.

First we need to get the table parameter into a JCO.Table object.

JCO.Table matSelTable = function.getTableParameterList().getTable("MATNRSELECTION");

Now we append a row to this empty table and add values to these fields.


matSelTable.setValue("vac*", "MATNR_LOW");

matSelTable.setValue("I", "SIGN");

matSelTable.setValue("CP", "OPTION");

Executing the BAPI

Now that the function object's input parameters have been initialized, we can execute the BAPI with out JCO.client object.

We have been providing the best information about Talk to SAP with JCo For you. If you liked this information, please tell your friends on Facebook, Twitter or Google plus using social buttons below.. ^_^. SAP Interfacing with VBA
Talk to SAP with JCo Rating: 4.5 by: Abdul Rahman Nasution


Post a Comment