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

Lock the all table

Former Member
0 Likes
2,409

HI All ,

I want to lock the Exclusive lock for table ,i.e in the process try to lock all the table for

update issue , how can i do that ,i read the help but i don't find where i can lock that all table .

by the way its recommended to lock the all table before update since

i want to use modify ZDB_table from table itab.

Regards

Chris

HI All ,

I want to lock the Exclusive lock for table ,i.e in the process try to lock all the table for

update issue , how can i do that ,i read the help but i don't find where i can lock that all table .

by the way its recommended to lock the all table before update since

i want to use modify ZDB_table from table itab.

Regards

Chris

7 REPLIES 7
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,708

Hello,

You can make use of DEQUEUE_E_TABLEE / ENQUEUE_E_TABLEE for locking the entire table.

BR,

Suhas

Read only

matteo_montalto
Contributor
0 Likes
1,708

Don't understand what your requirements are... If you just need to update a DB Z table from an itab, you should not deal with a lock management since that's assured by the way the system works with DB tables; an update/mod access to a DB table automatically prevents concurrent mod. access to avoid inconsistencies.

You might want to check before any DB access if a certain DB table is in a lock queue. Have a look at this FM: ENQUEUE_READ.

Hope this helps

Read only

RaymondGiuseppi
Active Contributor
1,708

You may

- lock the whole table SM30 like via lock object E_TABLE or E_TABLEE

CALL FUNCTION 'ENQUEUE_E_TABLE'
     EXPORTING
          tabname      = 'MARA'
     EXCEPTIONS
          foreign_lock = 1.

- lock the whole set of keys using a wildcard key via the lock object assiociated to records of the table

CALL FUNCTION 'ENQUEUE_EMMARAE'
 EXPORTING
   mandt                = sy-mandt
*  MATNR                = " generic value will lock whole table
 EXCEPTIONS
   foreign_lock         = 1
   system_failure       = 2
   OTHERS               = 3.

But be aware that the lock tools will only lock vs other reports using the same logic/FM. (chek in SM12)

Also read documentation like [The SAP Lock Concept (BC-CST-EQ) |http://help.sap.com/saphelp_nw70/helpdata/en/c2/2d7037ecc92a7ee10000009b38f8cf/frameset.htm] and samples like [Example Program: SAP Locking|http://help.sap.com/saphelp_nw70/helpdata/en/41/7af4c8a79e11d1950f0000e82de14a/frameset.htm]

Regards,

Raymond

Read only

0 Likes
1,708

HI Raymond ,

i need lock the table since there is process that read data from the table (via paging process i.e 1000 records in one request ) and

this read process can take more than hour so to avoid inconsistency i need to use locking concept

do u think that i need to use the lock for all the table for update (like ENQUEUE_E_TABLE )

and for read process to use read lock

what do u think ?

BR

Chris

Read only

0 Likes
1,708

You must lock the table the same way that the other processes use to update the table, if they lock by records use the enqueue object associated to the table, if they lock the table via lock object E_TABLEE use this one, if they perform wild update of the table, no luck. You have to look for other processes which update the table. (try SM12 to watch)

If this is the only program that update the table, use ENQUEUE_E_TABLEE so only one instance will be able to lock the file.

Regards,

Raymond

Read only

Former Member
0 Likes
1,708

hai,

as per your requirement before you update data into database table it should be locked for that use function module Enque. after the updation you should release the lock with Deque function module. use sy-subrc if data is getting updated then only table should get locked.

to check wether table is locked or to release any lock if necessary go to t-code sm12.

Read only

Former Member
0 Likes
1,708

TRY with sm12