‎2009 Jul 31 3:46 PM
HI all,
I am updating records of vbap table. so i want to lock those records while am updatin them .
which FM's should i use to update them ?
‎2009 Jul 31 3:57 PM
Hi ,
check out function modules:
ENQUEUE_E_TABLE
DEQUEUE_E_TABLE
Regards,
Himanshu
‎2009 Jul 31 5:53 PM
Hi,
Use the below FMs:
Lock table - ENQUEUE_E_TABLE
Instead of locking the complete table you can lock the table entry using its primary key...you will have to give its name in 'VARKEY' parameter. Also you can use 'WAIT' in case the entry is lock, it will wait for a second and then again try locking the table. More details you can go through the FM documentation.
Unlock table - DEQUEUE_E_TABLE
Regards,
Saba
‎2009 Aug 03 9:49 AM
Thanks for ur replies Himanshu and Sayed,
I have already used these FM's. But i didnt feel like it is working. I went in debugging mode and executed ENQUEUE FM and the i went in VA02 transaction and for the same sales order i tried updaing the quantity and it is updated in the table.
How come this has happened even though i have locked the table with the help of FM. ?
I have used the FM something like this :
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
MODE_RSTABLE = 'E'
TABNAME = 'VBAP'
VARKEY = 'VBELN'
X_TABNAME = ' '
X_VARKEY = ' '
_SCOPE = '2'
_WAIT = ' '
_COLLECT = ' '
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3
.
IF sy-subrc EQ 0.
UPDATE vbap FROM TABLE li_vbap.
CALL DEQUEUE.
ENDIF.
‎2009 Aug 03 9:54 AM
Hi,
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
MODE_RSTABLE = 'E'
TABNAME = 'VBAP'
VARKEY = 'VBELN'
X_TABNAME = ' '
X_VARKEY = ' '
_SCOPE = '2'
_WAIT = ' '
_COLLECT = ' '
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3
VARKEY has to be passed the variable key on which you want to lock the table like the sales order number in place of vbeln pass the actual sales order number and then check.
Also this is only a lock at the table level so in the transaction you migth still be able to save data which is getting stored in some other table.
‎2009 Aug 03 9:52 AM
Call VA02 on any sales order, then call SM12 on another session, you should see the lock, double-click give you the object to use : EVVBAKE "Sales document (exclusive)"
So use FM DEQUEUE_EVVBAKE and ENQUEUE_EVVBAKE
NB 1 : ENQUEUE_E_TABLE is only useful for SM30 transaction an some DDIC operations to lock the whole table vs those type of transactions.
NB 2 : Lock the record at the start of your program, else the data will change between your SELECT from database and your ENQUEUE
NB 3: Don't update VBAP with open SQL statements, better use BAPI_SALESORDER_CHANGE or equivalent function/tool
Regards,
Raymond
‎2009 Aug 03 10:56 AM
Hi Sunny,
The code says:
if sy-subrc = 0.
then update for ENQUEUE function module.
Doesn't that mean if the table is locked then update.... Please correct me if I am wrong.
‎2009 Aug 03 2:41 PM
Thanks for all your replies..
I am using the standard sales order lock FM to lock it
lock : ENQUEUE_EVVBAKE
unlock : DEQUEUE_E_TABLE
‎2009 Aug 03 2:44 PM
‎2009 Aug 03 2:50 PM
Sorry that was a typo..
ya i am using DEQUEUE_EVVBAKE to unlock .
Thanks Raymond for correcting me .
Edited by: Termi S on Aug 3, 2009 3:51 PM