cancel
Showing results for 
Search instead for 
Did you mean: 

Keep connection opened for loop

Former Member
0 Kudos

Hello Community!

I'm using JCO to connect a Flex application to a backend SAP System.

This is how I connect to the system:

- Edit configuration file for SAP System

- JCoDestination dest = JCoDestinationManager.getDestination(configurationFile)

- JCoFunction func = dest.getRepository.getFunction('myFunction')

- func.execute(dest)

I think that the connection is established when I execute the JCoFunction and then closes inmediatly after the execution is done.

The issue I'm having is that I have a RFC FM in SAP that is really fast (at least in SAP). I'm calling this FM via the JCo in a Loop and it's taking forever.

I think that the long response time comes from the connection... But don't know how to resolve it but creating a FM that call myfunction in a Loop and the returns it to Java...

Thanks for any help you can provide.

Regards,

BS_C3

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

By default JCo 3 uses connection pools. You can check the connection parameters in interface DestinationDataProvider. Here you can especially check out parameters jco.destination.expiration_time and jco.destination.expiration_check_period.

So connections are reused (not closed) as long as you don't create new destination objects with each call. Note that usually there's quite some overhead with the first invocation of an RFC call if you have to retrieve the metadata from a SAP repository. I.e. if you trace the calls you'll see that initially there's quite a few calls to figure out the function module interface of the called RFC and all corresponding parameters (e.g. if structures or tables are used those have to be retrieved as well). So you can gain some performance by adding the metadata of the used functions to the repository (or usage of a JCoCustomRepository and loading for example saved metadata before executing the RFC calls).

To check performance I'd enable tracing and possibly look at some of the other options for measuring performance (e.g. check out JCoDestination.setThroughput() and other options).

Cheers, harald