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: 

Lock custom tables

Former Member
0 Kudos

Hi,

I am writing program to upload data from excel to custom tables.

Here i add/ update/delete records from the table based on entries from excel sheet.

While i run this program, how do i maintain locks on the table, so that any other user is not modifying the tables at the same time.

Points will be awarded immediately.

Thanks

5 REPLIES 5

gopi_narendra
Active Contributor
0 Kudos

create lock objects in SE11 for that table.

then it create 2 function modules enqueue_<lockobject> and dequeue_<lockobject>

Use the FM's to lock and unlock

<b>the lock object name should always start with E.</b>

http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eef3446011d189700000e8322d00/content.htm

Regards

Gopi

Former Member
0 Kudos

you have to use lock objects pls go through this

<a href="http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm">http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm</a>

regards

shiba dutta

former_member194669
Active Contributor
0 Kudos

Hi,

aRs

mohammed_moqeeth
Active Participant
0 Kudos

<b>Lock objects</b> are used to lock the database table while making the modifications on the database table.

you can create your own lock objects using SE11.

if you create lock objects on any table system will create two function modules.

<b>1.ENQUEUE....

2.DEQUEUE.....</b>

first one is used to lock the table

second one used to removing lock on the table.

<b>This lock object</b> facilitates synchronous process. That is suppose if you are changing the table entries, and simultaneously there might be several programs running in the background or by anything else which also does changes to the same table. In this case you can lock the table so that other program will not able to update/insert/ do any other operation unless or until your program executes successfully.

You can create lock objects for this purpose in transaction SE11. SAP by default create 2 function modules. One for locking ( Enqueue) and other for unlocking ( Dequeue ). You can call these function module in appropriate places in your program.

ex...

*----


lock Table

CALL FUNCTION 'ENQUEUE_E_TABLE'

EXPORTING

tabname = table_name

EXCEPTIONS

foreign_lock = 1

system_failure = 2

OTHERS = 3.

*----


Unlock Table

CALL FUNCTION 'DEQUEUE_E_TABLE'

EXPORTING

tabname = table_name

<b><u>check the below links:</u></b>

http://help.sap.com/saphelp_40b/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm

Regards,

Moqeeth.

Former Member
0 Kudos

To lock the whole table, you can use this generic object FM ENQUEUE_E_TABLE

here you pass upu custom table name.

If you want to lock on a key value(entries) than you can create a lock object in SE11.

Regards,

A.Singh