cancel
Showing results for 
Search instead for 
Did you mean: 

When should we call disconnectIfAlive()

Former Member
0 Kudos

Hi,

I have a question , when should we call disconnectIfAlive() ?? , if we dont call the method when will the

connection be freed??.

I have a application in that i will be calling "Execute()" method on the BAPI Model when ever user selects

a item in the dropdownlist ( the selected value will be passed as a parameter to the BAPI), user can select the list multiple times .. so i might be calling the same models "Execute()" many times in the application .

So is it good to call disconnectIfAlive() after execute every time [ Will the performance be slow as it has to get new connection when we call execute], or should i just leave it for th DynPro run time to take care abt freeing the connection.

I am considering about the performance if we call disconnectIfAlive after execute , please advice.

Regards,

Ravi.

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member751941
Active Contributor
0 Kudos

Hi Ravi,

you have to use the "disconnectIfAlive() " when you will perform "UPDATE" operation using "BAPI".If you don't disconnect the model instance other user will not be able to update the record. Its lock the record until and unless you disconnect the model instance.

finally

{

SaveModel svModel = (SaveModel)WDModelFactory.getModelInstance(SaveModel.class);

svModel.disconnectIfAlive();

}

Regards,

Mithu

Former Member
0 Kudos

What if i am not performing any UPDATE operation , When will the connection get freed if i dont call "disconnectIfAlive" and if i call the BAPI for the second time in my application will the same connection be used or will it create new connection when ever we call execute ??

Former Member
0 Kudos

Hi

1. If you don't call externally disconnectIfAlive WD Framework will call automatically.

2.If you call second time BAPI , Same connection will be used.

But GoodPractice is call disconnectIfAlive in the final Block.

THx & Rgds

SS