SAP 6.5 Problem in lockSession and releaseSession

We are using SAP Adaper 6.5

we receive JDBC Insert notifications and a serial trigger have been created to subscribe this notification document
then we map those fields against SAP BAPI fields and call the BAPI by passing these values.

Code snippet
lock session
Invoke the BAPI
REceive the return parameters from the BAPI
Check for MSG varaible
when MSG=“S”
Release lock
when MSG= “E”
Release lock

The problem we face is , suppose the table is inserted with 10 records in on shot then we get 10 different notification document been published, here the first notification document is picked by the trigger and calls the bapi and it works as expected. But on the consecutive calls we receive from the BAPI that webMethods User have not yet released the lock for this BAPI, but here in our code we have release lock which will release connection resources. but in originality for the second call the BAPI throws that it locked by the webMethods user… so even the release lock invoke is success in first call it doesnot actually releases the resources from SAP side… Could anyone have faced this issue… Please help me to resolve this issue.

SAP does not synchronous apply updates or unlocks tables or bapis. You may need to but a delay or retry logic in your code to perform the bapi call.

I do agree with as Bradley suggested,put some delay logic (thread sleep service) and try it.


Don’t play around with “sleep” or similar stuff.

The correct way to do this: “” has an optional parameter called “wait”. If you set this to “true”, the backend waits until the DB update task has finished, before returning to the external caller.