JCO SERVER CONNECTION

Source: Internet
Author: User
Jco server connection instructions

JCo (Sap Java Connect 22:03:02 read 66 comments 0 font size: LargeMediumSmall subscription

1. Key Points of Jco Server Connection

1) Implement the JCoServerFunctionHandler and the coding to be executed when the call is already ed.

2) Create an instance for your JCoServer implementation and start it with start ().

 

1.1. Establish a connection with the sap end

Static

{

Properties connectProperties = new Properties ();

ConnectProperties. setProperty (DestinationDataProvider.JCO_ASHOST, "10.52.41.3 ");

ConnectProperties. setProperty (DestinationDataProvider.JCO_SYSNR, "02 ");

ConnectProperties. setProperty (DestinationDataProvider.JCO_CLIENT("800 ");

ConnectProperties. setProperty (DestinationDataProvider.JCO_USER, "CRCTEST ");

ConnectProperties. setProperty (DestinationDataProvider.JCO_PASSWD("12345678 ");

ConnectProperties. setProperty (DestinationDataProvider.JCO_LANG, "En ");

CreateDataFile(DESTINATION_NAME1, "jcoDestination", connectProperties );

ConnectProperties. setProperty (DestinationDataProvider.JCO_POOL_CAPACITY, "3 ");

Connectproperties. setproperty (destinationdataprovider.JCO_PEAK_LIMIT, "10 ");

CreateDataFile(DESTINATION_NAME2, "Jcodestination", connectproperties );

Properties servertproperties = new properties ();

Servertproperties. setproperty (serverdataprovider.JCO_GWHOST, "10.52.41.3 ");

Servertproperties. setproperty (serverdataprovider.JCO_GWSERV("3302 ");

Servertproperties. setproperty (serverdataprovider.JCO_PROGID, "Jcodemo ");

Servertproperties. setproperty (serverdataprovider.JCO_REP_DEST, "ABAP_AS_WITH_POOL ");

ServertProperties. setProperty (ServerDataProvider.JCO_CONNECTION_COUNT, "2 ");

CreateDataFile(SERVER_NAME1, "JcoServer", servertProperties );

}

ServerDataProvider.JCO_GWHOSTSet the IP address of the server, ServerDataProvider.JCO_GWSERVSet the port number on the sap side.

1.2. StfcConnectionHandle class handles RFC

The fcconnectionhandle class inherits the JCoServerFunctionHandle interface and overwrites the handleRequest (JCoServerContext serverCtx, JCoFunction function) method.

A New defaserverserverhandlerfactory. FunctionHandlerFactory object uses the registerHandler (Function Name, stfcConnectionHandler) method. The previous parameter is the Function to be called by the sap end, And the next parameter is an instance of the StfcConnectionHandler class.

Then, use the setCallHandlerFactory (DefaultServerHandlerFactory. FunctionHandlerFactory factory) method of server name to use server. start.

HandleRequest (JCoServerContext serverCtx, JCoFunction function) function is supplemented:

Function. getimpparameparameterlist () is used to obtain the exporting parameter passed by the sap call Function.

Function. getExportParameterList (). setValue () is used to set the importing parameter.

 

 

1.3. Simple Server Connection, With Exception Listener Server Connection, and tRFC Server Connection

1.3.1. With Exception Server Connection on the basis of Simple Server Connection, register Listener Class.

MyThrowableListener eListener =NewMyThrowableListener ();

Server. addServerErrorListener (eListener );

Server. addServerExceptionListener (eListener );

 

MyThrowableListener inherits the JCoServerErrorListener and JCoServerExceptionListener interfaces and overwrites the servererroccurred () and serverExceptionOccurred () methods.

 

1.3.2. Based on the Simple Server Connection, tRFC Server Connection uses TIDHandler to implement transaction-type Connection.

 

MyTIDHandler = new MyTIDHandler ();

Server. setTIDHandler (myTIDHandler );


 

The MyTIDHandler class inherits the JCoServerTIDHandler interface and overwrites the checkTID (), commit (), rollback (), confirmTID (), and execute () methods.

A HashTable storage status (CREATED, EXECUTED, COMMITTED, ROLLED_BACK, CONFIRMED), TIDState state = availableTIDs. get (tid) is used ). If status is null, it is changed to CREATED and TRUE is returned. If status is CREATED or ROLLED_BACK, TRUE is returned. Otherwise, FALSE is returned.

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.