07-13-2007 3:42 AM
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
07-13-2007 3:45 AM
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
07-13-2007 3:46 AM
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
07-13-2007 3:57 AM
07-13-2007 4:13 AM
<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.
07-13-2007 4:51 AM
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