Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Prevent Commit from deleting DB-locks

philippdoelker
Participant
0 Likes
2,193

Hello Community,

is there a possibility to prevent a Commit Statement from deleting DB-locks?

I'm working on a program that commits an DB-Update during execution but I don't want it to remove a DB-lock (Set by Call Function 'Enqueue_E_DBTable), as the DB-lock controls the execution of an Do-Loop.

Thank you.

Regards,

Philipp

1 ACCEPTED SOLUTION
Read only

Clemenss
Active Contributor
1,745

Hi Philip,

pleas give more details.

As Sandra said: Enqueue locks are so-called cooperative locks. That means there is no real lock at database level (as i.a. with SELECT SINGLE ... FOR UPDATE). But other programs should try to set the same lock before updating the database.

The 'Master' of the process, i.e. the top-most level in the call hierarchy is allowed to issue a COMMIT WORK (preferedly use function BAPI_TRANSACTION_COMMIT).

Implicit commits are done at any program interruption as screen displays, RFC calls and such. They don not affect any locks.

The COMMIT WORK (as issued by function BAPI_TRANSACTION_COMMIT) will trigger execution of all function modules called IN UPDATE TASK and PERFORM ON COMMITs.

Regards Clemens

6 REPLIES 6
Read only

Sandra_Rossi
Active Contributor
1,745

Enqueue function modules set an ABAP lock (lock in ABAP system only, SM12), not a DB lock (lock by the database system).

You may retain the ABAP locks by committing at database level using CALL FUNCTION 'DB_COMMIT'.

Read only

0 Likes
1,745

But then what happens when SAP does either an implied commit,  or a 'COMMIT WORK', or even a 'ROLLBACK WORK' ?

Read only

1,745

I have given an answer which possibly fits the question, I can't image all scenarios that could be behind the question!

I don't know whether the program is custom or standard. I don't know whether the COMMIT is done by the standard or not. I don't know whether the OP wants to run update function modules with the commit, etc.

Read only

Clemenss
Active Contributor
1,746

Hi Philip,

pleas give more details.

As Sandra said: Enqueue locks are so-called cooperative locks. That means there is no real lock at database level (as i.a. with SELECT SINGLE ... FOR UPDATE). But other programs should try to set the same lock before updating the database.

The 'Master' of the process, i.e. the top-most level in the call hierarchy is allowed to issue a COMMIT WORK (preferedly use function BAPI_TRANSACTION_COMMIT).

Implicit commits are done at any program interruption as screen displays, RFC calls and such. They don not affect any locks.

The COMMIT WORK (as issued by function BAPI_TRANSACTION_COMMIT) will trigger execution of all function modules called IN UPDATE TASK and PERFORM ON COMMITs.

Regards Clemens

Read only

0 Likes
1,745

Hi,

first of all I have to correct myself, as Sandra mentioned I used an ABAP lock, not a DB-lock.
Although the Issue is already solved I'll try to give you some more detail:
The Report is a Custom Report, created to monitor a Business Process. The monitoring is implemented by a demon running (in an endless do-loop). The Demon controls itself at the end of the loop by testing if the lock can be set or not (lock can be set means lock was deleted by someone -> Demon should stop). This control mechanism is implemented from outside with a control transaction that creates a DB-Entry (on which afterwards the Demon sets the lock). In the control transaction you can also delete the DB-Entry, so the ABAP-lock is also deleted and the Demon stops running. Hope this is comprehensible.

Problem was that the lock disappeared after a Commit Statement in the report and thereby the Demon stopped. Solved this issue by manipulating the _scope parameter of the FM 'Enqueue..'.

Thank you all for your replies!

Regards,

Philipp

Read only

matt
Active Contributor
0 Likes
1,744

Perhaps you can use a secondary database connection in some way? But as Clemens says - we need a bit more detail.