SAP Java Connector (JCo)

Source: Internet
Author: User
Tags rar

JCO is a high-performance, JNI-based middleware that implements the RFC (Remote Function Call) protocol of SAP.

1 , JCo the installation

Download Jco from Http://files.cnblogs.com/byfhd/jco.rar and copy Librfc32.dll and Sapjcorfc.dll to Winnt "SYSTEM32" after decompression, Add Sapjco.jar to the project's classpath.

2 , with SAP the connection

The JCO supports two modes of connection, direct connections and connection pools.

Direct connections:

Import com.sap.mw.jco.*;

Public TutorialConnect1 () {
JCO. Client mconnection;
try {
Mconnection = Jco.createclient ("001",//SAP Client
"",//UserID
"* * * *",//password
NULL,//language
"",//server host name
                                                            "XX");               // System number          mconnection.connect ();                                                                                 
Mconnection.disconnect ();
} catch (Exception ex) {
}
}

Connection pools:

Static final String pool_name = "POOL";
Public TutorialConnect2 () {
JCO. Client mconnection;
try {
JCO. Pool pool = Jco.getclientpoolmanager (). Getpool (Pool_name);
if (pool = = null) {
Orderedproperties properties = orderedproperties.load ("/logon.properties");
Jco.addclientpool (Pool_name,//POOL NAME
5,//maximum number of connections
Logonproperties); Properties
}
Mconnection = Jco.getclient (pool_name);
} catch (Exception ex) {
} finally { Returns a connection to the connection pool, or causes no connection to be available
Jco.releaseclient (mconnection);
}
}

Definition of logon.properties file:

jco.client.client=001
Jco.client.user=userid
jco.client.passwd=****
Jco.client.ashost=hostname
jco.client.sysnr=00

3 , the SAP to operate

There are jco.repository objects in SAP that contain the run environment metadata for the RFM of SAP.

JCO. Repository mrepository;
Mrepository = new JCO. Repository ("Arasoft", mconnection);
The constructor contains two parameters, the first one is an arbitrary name, and the second is the connection pool or Jco.client object.

The Ifunctiontemplate object contains a specific RFM meta-data, JCO. The function represents an RFM that contains all the parameters. The relationship between them is similar to the relationship between class and object in Java.

Ifunctiontemplate ft = mrepository.getfunctiontemplate ("Bapi_salesorder_getlist");
FT NULL indicates no corresponding RFM found in SAP
if (ft = = null) return null;
JCO. function function = Ft.getfunction ();

JCO. The Parameterlist object contains input, output, and table parameters that do the function.

Client = Jco.getclient (SID); Get the client from the pool
JCO. Parameterlist input = Function.getimportparameterlist ();
Set the parameter, the parameter name is the second parameter, the parameter value is the first parameter,
Input.setvalue ("0000001200", "Customer_number");
Input.setvalue ("n", "sales_organization");
Client.execute (function);


Download Jco:http://files.cnblogs.com/byfhd/jco.rar

SAP Java Connector (JCo)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.