04-14-2005 5:43 PM
Hi all,
I have a function module which updates custom table, here while going to update i would like to lock the table and after completion of updation I have to unlock the data, have you got my point ... can anybody tell me the procedure of locking mechanism... needed detailed code
Thanks & Regards
Rajesh
04-14-2005 5:55 PM
You need to create a lock object for your table via SE11.
The name of the lock object should be your table name with an "E" in front. After creating your lock object, there will be two function modules generated.
ENQUEUE_<Lock Object Name>
DEQUEUE_<Lock Object Name>
You use these function modules in your program to get locks.
Here is a code sample of a custom lock object over a custom table named ZPT_DET, with one key field REQNO.
call function 'ENQUEUE_EZPT_DET'
EXPORTING
* MODE_ZPT_DET = 'E'
MANDT = SY-MANDT
REQNO = P_REQNO
* X_REQNO = ' '
* _SCOPE = '2'
* _WAIT = ' '
* _COLLECT = ' '
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3
.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
Hope this helps.
Regards,
Rich Heilman
04-14-2005 5:50 PM
Use SE11 to create a Lock Object. When you create the lock object, you specify which table it is for, and then in the Lock Parameter tab, you specify the key fields for the lock. Two function modules will be created when you activate the lock object. You can find the function modules by displaying your lock object, and then go to meny path Goto / Lock modules. One FM will start with ENQUEUE. Use this FM to lock the data. The other FM starts with DEQUEUE. Use this FM to unlock the data.
Brian
04-14-2005 5:55 PM
You need to create a lock object for your table via SE11.
The name of the lock object should be your table name with an "E" in front. After creating your lock object, there will be two function modules generated.
ENQUEUE_<Lock Object Name>
DEQUEUE_<Lock Object Name>
You use these function modules in your program to get locks.
Here is a code sample of a custom lock object over a custom table named ZPT_DET, with one key field REQNO.
call function 'ENQUEUE_EZPT_DET'
EXPORTING
* MODE_ZPT_DET = 'E'
MANDT = SY-MANDT
REQNO = P_REQNO
* X_REQNO = ' '
* _SCOPE = '2'
* _WAIT = ' '
* _COLLECT = ' '
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3
.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
Hope this helps.
Regards,
Rich Heilman
04-15-2005 12:15 PM
Thank you my friends Bryan and Rich, your help is appreciatable.... i've solved it
Once again thanks for your nice cooperation
Regards
Rajesh