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

ENQUEUE DEQUEUE FM's for updating VBAP table record

Former Member
0 Likes
7,164

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 ?

9 REPLIES 9
Read only

Former Member
0 Likes
3,546

Hi ,

check out function modules:

ENQUEUE_E_TABLE

DEQUEUE_E_TABLE

Regards,

Himanshu

Read only

Former Member
0 Likes
3,546

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

Read only

Former Member
0 Likes
3,546

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.

Read only

0 Likes
3,546

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.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
3,546

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

Read only

Former Member
0 Likes
3,546

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.

Read only

0 Likes
3,546

Thanks for all your replies..

I am using the standard sales order lock FM to lock it

lock : ENQUEUE_EVVBAKE

unlock : DEQUEUE_E_TABLE

Read only

0 Likes
3,546

If you use ENQUEUE_EVVBAKE, use DEQUEUE_EVVBAKE or COMMIT WORK to release the lock, and not DEQUEUE_E_TABLE.

Regards,

Raymond

Read only

0 Likes
3,546

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