Application Development 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: 

ENQUEUEs and COMMITs

Former Member
0 Kudos
1,352

Hi everybody!

I have the following problem:

I have to make sure that my program - which has a long running time - is running only once at a time.

My first idea was to create (or use an existing) lock object and call the appropriate ENQUEUE_xxx function module. However, I just read in the online documentation that a COMMIT statement will clear and release all lock entries made by my program. My program calls various BAPIs and therefore I COMMIT quite often. Will this clear the locking entry?

I. e. if my program reaches the first COMMIT statement will it be possible to execute the program in another process again? If so: Are there any alternatives?

Regards,

Joerg

7 REPLIES 7

Former Member
0 Kudos
347

I guess BAPI_TRANSACTION_COMMIT will just commit the changes in R/3 via BAPI calls, so it should not effect the locks

0 Kudos
347

Hi everyone!

I just did some debugging and confirmed that the first COMMIT in my program clears the lock (I used FM ENQUEUE_E_TABLE for this purpose).

Is there any other way to set s system-wide lock?

Regards,

Joerg

0 Kudos
347

Hi,

You are using ENQUEUE_E_TABLE for locking , by giving the table name, my suggestion is why don't you create lock objects for the tables as trying to lock.

I checked with ENQUEUE_EANLA (for my testing) after giving commit/bapi_transaction_commit still lock will be there in the table level upto DEQUEUE is applied.

Former Member
0 Kudos
347

It releases the database locks, not the SAP locks.

Rob

Former Member
0 Kudos
347

hi

chk this thread

https://forums.sdn.sap.com/click.jspa?searchID=4820751&messageID=839219

if helpful, reward

Sathish R

0 Kudos
347

Hi,

Thanks for the link, but it still doesnt work for me...

Conceptually, my program looks like this:


START-OF-SELECTION.

CALL FUNCTION 'ENQUEUE_E_TABLE'
...
LOOP AT it_veeery_biiiig_table.
  CALL FUNCTION 'BAPI_xxx'
  ...
  COMMIT.

  CALL FUNCTION 'BAPI_xxx'
  ...
  COMMIT.
ENDLOOP.

The first COMMIT clears the lock. From that moment on it would be possible to start the program again - this should not be allowed, though.

Any other ideas?

Regards, Joerg

0 Kudos
347

Hi Joerg,

We had a requirement like this. As you said the first COMMIT deletes all SAP and DB Locks.

For this we created a customized DB Table with MANDT and PROGNAME fields. As soon as the program execution starts we check if there is an entry in this table. If NO we make an entry and proceed. If there is an entry we come out of the program.

Once the execution is completed (for the person for whom the INSERT was succesfull) we delete the entry from the DB table. This is not a GOOD Solution but yes, this is the way we made it worked. At the END OF THE PROGRAM PUT A DELETE STATEMENT TO DELETE THE ENTRY MADE FROM THE DB TABLE. Try to use a customized table for this purpose.

Please let me know if further details are required.

Regards,

Goutham.