cancel
Showing results for 
Search instead for 
Did you mean: 

SAP JCO Server Programming:Set Up Questions

Former Member
0 Kudos

Hi SDN Folks,

we have requirement to use SAPJCO as server component, call from SAP to Java Application only.

I gone through stepbystepserver.java program from the JCO Package we got.

I have question on:

1: what is ABAP_AS_WITH_POOL and WITHOUT_POOL : My understanding was this property is useful for Client programming or use case where Java Application talks to SAP.

2. JCO_POOL_CAPACITY and JCO_PEAK_LIMIT, really matters for server programming, because we are already in the session and making RFC(TCP/IP) Call so work process is already occupied.

Java Experts can you put some light on these questions.

THank You

PP

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

yes you right. Both parameters are really matters for server programming model.

The files ABAP_AS_WITHOUT_POOL.jcoDestination and ABAP_AS_WITH_POOL.jcoDestination

are only for client programming model. If you using the JCo Server programming model

you only need the following parameters

Below some steps for starting with JCo Server development:

1. Create yor own DestinationDataProvider and ServerDataProvider

     public class OwnDestinationDataProvider implements DestinationDataProvider { }

     public class OwnServerDataProvider implements ServerDataProvider { }

2. Create your own propertie file

Without an own propertie file the server implememtation is searching for a file that ends

with *.jco (default implementation)

2. Create your own JcoServer Class and register both DataProvider

3. Create your own handler classes

Handler classes are implemented as listener classes and waits for incoming requests from

ABAP System.

4. Register the function modules from ABAP

The following sourcecode demonstrate an easy example to implement an JCo Server

          private static final String JCO_SERVER_PRODIG = "jco.server.progid";

 

          private static final String FUBA_OWN = "own.fuba";

          public void startServer(Properties prop) {

                    JCoServer server = null;

 

                    try {

                              /**

                               * Instancename of Servers

                               *

                               */

            

                              OwnDestinationDataProvider destination_data_provider = new OwnDestinationDataProvider(prop);

                              OwnServerDataProvider server_data_provier = new OwnServerDataProvider(prop); 

                    

                              Environment.registerDestinationDataProvider(destination_data_provider);

                              Environment.registerServerDataProvider(server_data_provier);

 

                              server = JCoServerFactory.getServer(prop

                                                  .getProperty(JCO_SERVER_PRODIG));

                    } catch (JCoException ex) {

                               ex.getMessage();

                    }

                    JCoServerFunctionHandler setOwnHandler = new SetOwnHandler(

                                        myTIDHandler, prop);

                    DefaultServerHandlerFactory.FunctionHandlerFactory factory =

                              new DefaultServerHandlerFactory.FunctionHandlerFactory();

                    /**

                     * Handler für die verschiedenen Funktionsbausteine werden registriert.

                     */

                    factory.registerHandler(prop.getProperty(FUBA_OWN),

                                        setOwnHandler);

                    server.setCallHandlerFactory(factory);

 

                    CustomServerStateListener slistener = new CustomServerStateListener();

        server.addServerStateChangedListener(slistener);

I hope the description brings light into the darkness... :

Best regards

Maik

Former Member
0 Kudos

Hi Maik,

Your information helped me on understanding what needed for Client programming vs server programming.

Can you tell me if I have to connect multiple back-end system then what I need to do.

Like in current scenario for DestinationDataProvider and ServerDataProvider, I can only assign one system and one program ID.

Thank You for your reply.

PP

Former Member
0 Kudos

Hi,

yes it is possible. The follwing example show how it works

First create the server

Next step is to define the different repositories

Next step to assign the different repositories to different servers

Now you can use the follwing code snippet to start the servers

    static void step2SimpleServer()

    {

        JCoServer server_erp;

        JCoServer server_crm;

        try

        {

            server_erp = JCoServerFactory.getServer(SERVER_NAME1);

            server_crm = JCoServerFactory.getServer(SERVER_NAME2);

        }

        catch(JCoException ex)

        {

            throw new RuntimeException("Unable to create the server " + SERVER_NAME1 + ", because of " + ex.getMessage(), ex);

        }

       

        JCoServerFunctionHandler stfcConnectionHandler = new StfcConnectionHandler();

        DefaultServerHandlerFactory.FunctionHandlerFactory factory = new DefaultServerHandlerFactory.FunctionHandlerFactory();

        factory.registerHandler("STFC_CONNECTION", stfcConnectionHandler);

        server_erp.setCallHandlerFactory(factory);

        server_crm.setCallHandlerFactory(factory);

       

        // additionally to step 1

        MyThrowableListener eListener = new MyThrowableListener();

        server_erp.addServerErrorListener(eListener);

        server_erp.addServerExceptionListener(eListener);

        server_crm.addServerErrorListener(eListener);

        server_crm.addServerExceptionListener(eListener);

       

        MyStateChangedListener slistener = new MyStateChangedListener();

        server_erp.addServerStateChangedListener(slistener);

        server_crm.addServerStateChangedListener(slistener);

       

        server_erp.start();

        server_crm.start();

        System.out.println("The program can be stoped using <ctrl>+<c>");

    }

   

    public static void main(String[] a)

    {

              step2SimpleServer();

    }

}

No go to your different backend system and call SE37 and call function module STFC_CONNECTION

Thats all......

Best reagards

Maik

Former Member
0 Kudos

Hi Maik,

This is really good.

I have one doubt on how to use multiple system connection through DestinationDataProvider and ServerDataProvider methods.

Let say requirement is to not create those files and use Method Approach for defining server and user details because through files we are exposing user id and password.

Is there any way I can use multiple systems connection through using these APIs.

Your earlier response showed that I can use that instead of create file approach. Need more info on how to use for multi system scenario.

Thanks

PP

Former Member
0 Kudos

Hi,

yes of course. For this case you need only create an propertie object instead to read a file. That's it...You can use the code snippet from my earlier response. In your ServerDateProvider constructor you use your propertie object

private Properties abapAsProperties = null;

    public OwnServerDataProvider(final Properties properties) {

        this.abapAsProperties = properties;

    }

During the starting JCo Server call the follwing code snippet

private OwnDestinationDataProvider destinationDataProvider = null;


private OwnServerDataProvider serverDataProvider = null;

private void registerDestinationProvider() {

                    if (!Environment.isDestinationDataProviderRegistered()) {

                              Environment

                                                  .registerDestinationDataProvider(this.destinationDataProvider);

                    }

                    if (!Environment.isServerDataProviderRegistered()) {

                              Environment.registerServerDataProvider(this.serverDataProvider);

                    }

          }

That's it....

Best regards

Maik

Former Member
0 Kudos

Hi Maik,

Yes I followed your code and for one connection its working, but if I have multiple system for server and backend connection its not working. do you think I am missing anything there?

Thanks

PP

Answers (1)

Answers (1)

Former Member
0 Kudos

if you have worked on SAP JCo Server component please share your thoughts.

Former Member
0 Kudos

Any document or example which I can look for??

Help is appreciated.

robertot4s
Active Participant
0 Kudos

Hi,

I have worked with JCo Server Programming. I followed the example from the JCo package:

examples/StatefulServerExample

In the javadoc you have also documentation about some of these parameters:

JCO_POOL_CAPACITY: Maximum number of idle connections kept open by the destination. A value of 0 has the effect that there is no connection pooling

JCO_PEAK_LIMIT: Maximum number of active connections that can be created for a destination simultaneously

Regards,

Roberto

Former Member
0 Kudos

Hi Roberto,

Thank you for your reply.  but for server programming do we need connection pooling because when JCO server start, it makes connection between sap and java application and when we make RFC call from SAP to java application we are utilizing same SAP session to process the request and get response.

even if I have one connection and at same time 10 users are trying to make connection its working fine then what is the difference to use conneciton pooling.

Thanks

PP    

robertot4s
Active Participant
0 Kudos

Hi,

It will always work fine. The difference is the performance and the concurrence:

- JCO_PEAK_LIMIT: Needed for concurrent processing in different threads.

- JCO_POOL_CAPACITY: This value indicates the number of connections that will be kept open in a pool. With value 0, every time that one connection is established, the connection should be open. With high message load it's better to keep the connections open in order to improve the performance.

Remember that always JCO_POOL_CAPACITY <= JCO_PEAK_LIMIT.

Regards,

Roberto