cancel
Showing results for 
Search instead for 
Did you mean: 

How to close a model object connection for Adaptive RFC?

Former Member
0 Kudos

Hi,

I'm calling two update RFC one after another in a single WebDynpro program. I like to close the session/connection after calling the first RFC. I'm using twp separate JCo connection for calling these two RFCs. Still I find both the RFCs are called in the same session.

Is there any way to close the JCo session from the code?

Thanks ,

Dipankar

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Diankar,

Yes, Jaydeep is correct. You have to add that code after executing that RFC.

Go through the following link:

Regards,

Bhavik

Former Member
0 Kudos

Hi Dipankar

If you want the framework to control the opening and closing of the connections , then use TASK_SCOPE when initializing the modelobjects ,in which case the connection will remain open, for the lifecycle of a single call.

The intialization should be as below

(CompanyCodeList is your model object)



CompanyCodeList compCode = (CompanyCodeList)WDModelFactory.getModelInstance(CompanyCodeList.class, WDModelScopeType.TASK_SCOPE); 
Bapi_Companycode_Getlist_Input bapIn = (Bapi_Companycode_Getlist_Input) compCode.createModelObject(Bapi_Companycode_Getlist_Input.class); 
wdContext.nodeBapi_Companycode_Getlist_Input().bind(new Bapi_Companycode_Getlist_Input()); 


Regards

Pran

Former Member
0 Kudos

Pran,

Using TASK_SCOPE force model object to be disconnected from model (and garbage collected later) right after request/response phase is ended. Therefor <b>you must not add such objects to context nodes</b>!!!

Valery Silaev

EPAM Systems

http://www.NetWeaverTeam.com

Former Member
0 Kudos

Hi Dipankar

1.Get the instance of the Model object

2. Get the JCO connection

3. Close the connection

Ex:

<Model Name> obj = (<Model Name>)wdContext.currentBapi_XXX_InputElement().model();

JCo.Client jcoclient = obj.getJCoClient();

Regards

NagaKishore

Former Member
0 Kudos

hi Dipankar,

Write these lines of code after executing the RFC.

<Model Name> anyName =

(<Model Name>)WDModelFactory.getModelInstance(<Model

Name>.class);

anyName.disconnectIfAlive();

Hope this helps.

Regards,

Jaydeep

Former Member
0 Kudos

Hi Jaydeep,

I am having problem in closing the JCO connection. When I used your code it throws below exception.

The type of model represented by class 'com.rak.model.Ztest_Function_Input' is not compatible for creation by WDModelFactory!

Your help appreciated.

Note: I am using content admin for JCO connection.

Regards,

Rakesh.

Former Member
0 Kudos

Hi NagaKishore,

I am having problem in closing the JCO connection. When I used your code it throws below exception <b>not compatible for creation by WDModelFactory!</b>.

The type of model represented by class 'com.rak.model.Ztest_Function_Input' is not compatible for creation by WDModelFactory!

Your help appreciated.

Note: I am using content admin for JCO connection.

Regards,

Rakesh.

Former Member
0 Kudos

Hi

In the Content administrator the parameters

Connection Timout (msec.) Maximum Waiting Time (msec.)

are used for the connection duration afret the waiting Time the connection will be clised

Kind Regards

Mukesh

Former Member
0 Kudos

Rakesh,

You get this error because your are suppling class of query (*_Input) but not class of complete model, check again:


<b><Model Name></b> anyName = 
(<b><Model Name></b>)WDModelFactory.getModelInstance(<b><Model Name></b>.class);
anyName.disconnectIfAlive();

VS