cancel
Showing results for 
Search instead for 
Did you mean: 

JCO - setConnectionProvider doesn't work

former_member182374
Active Contributor
0 Kudos

Hi all,

I have a Web Dynpro project that I need to maintain.

The project uses 9 models (each model has 1 RFC).

I know that the best practice it to put all the RFCs in the same model but I can't do it and I'm looking for a workaround.

One way is to use disconnectIfAlive method - connections are being set on demand but I'm losing the ability to use pooling.

Second way is to use the set/get connectionProvider:

I know which RFC run first, before I executed the RFC, I used setConnectionProvider and save it in the context (in IWDDynamicModel object).

Beofre I run the rest of the RFCs, I use getConnectionProvider and I use the IWDDynamicModel from the context ( inputX.modelInstance().setConnectionProvider(rfcConnection) )

When I run SM04 in R3, I see that each user (in the same session) opens several connections instead of one.

How do I fix it?

Thanks,

Omri

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Omri,

I tried setConnectionProvider method it did not work. Still it is creating many connections(SM04 ) in R/3. Any solution from any one?

Regards,

Ramana.

Former Member
0 Kudos

Omri Cohen

how did you solve the set connectionprovider? do you have example code or steps to do for me?

regards

former_member182374
Active Contributor
0 Kudos

Hi Eoin Cronan,

The best way is to put ALL your RFCs in one model.

If you can't do that than use the following workaround:

1) Define a variable of type 'com.sap.tc.webdynpro.modelimpl.dynamicrfc.IWDDynamicRFCModel' in the context (let's call it 'RfcConnection')

2) After you run your first RFC in the project, write the following code

IWDDynamicRFCModel rfcConnection = <model1l>.modelInstance().getConnectionProvider();
    wdContext.currentContextElement().setRfcConnection(rfcConnection);

3) For all RFCs besides the first one write the following code before the 'execute' statement

<model2>.modelInstance().setConnectionProvider(wdContext.currentContextElement().getRfcConnection());

Omri

Former Member
0 Kudos

Omri,

First, make sure that you are not counting metadata connection along with data connection. Every RFC model has one metadata connection and one data connection. With setConnectionProvider you are changing data connection and it's impossible to change metadata connection programatically at all. So please verify what connections you are counting.

Valery Silaev

SaM Solutions

http://www.sam-solutions.net

former_member182374
Active Contributor
0 Kudos

Hi Valery,

It's the same METADATA connection for all models/rfcs.

I don't want to change the METADATA, just the MODELDATA.

The problem is with the MODELDATA connections (each user creates a lot of connections in R3. I know it because I use ticket for MODELDATA and fixed (system) user for METADATA)

Omri

Former Member
0 Kudos

Omri,

Then it seems that your assumption about "first invoked RFC" is wrong. Seems like other RFC-s has chance to be executed at least once before you redefined data connection. Probubly via some supply functions or via code executed from wdDoInit of defaulr visible view controllers / component controllers. This is next item to check.

Valery Silaev

SaM Solutions

http://www.sam-solutions.net

former_member182374
Active Contributor
0 Kudos

Hi Valery,

I have a log in my application which writes every function/rfc name and execution time.

From this log I see which RFC is invoked first.

The output of this rfc is used as input in other RFCs so I'm sure it is the first.

Maybe I did something wrong in the implementation of the code.

I will try to post some code.

Omri