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: 

FM to lock the Table

Former Member
0 Kudos
372

Could anybody check and tell me whether Function Module ENQUEUE_E_TABLE

and DEQUEUE_E_TABLE are working fine and if it is so let me know the Parameters used for it.

Full reward points for issue solver.

Regards,

Amol

2 REPLIES 2

Former Member
0 Kudos
139

hi..

check out the following documentation

Lock objects 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.

1.ENQUEUE....

2.DEQUEUE.....

first one is used to lock the table

second one used to removing lock on the table.

*----


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

check this link :

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

_SCOPE = 1: The lock is not sent to the update program. The lock is removed when the transaction is ended.

_SCOPE = 2: The lock is sent to the update program. The update program is responsible for removing the lock. The dialog program which requested the lock no longer has an influence on the lock behavior. This is the standard setting for the ENQUEUE function module.

_SCOPE = 3: The lock

Managingin lock entries

http://help.sap.com/saphelp_nw04/helpdata/en/37/a2e3ae344411d3acb00000e83539c3/frameset.htm

http://help.sap.com/saphelp_nw04/helpdata/en/7b/f9813712f7434be10000009b38f8cf/frameset.htm

http://help.sap.com/saphelp_nw04/helpdata/en/cb/168237d30d974be10000009b38f8cf/frameset.htm

<b>Reward points if useful</b>

Regards

Ashu

Former Member
0 Kudos
139

Hi Amol,

Try this,

  • testing the locking of tables...

data:

varkey like rstable-varkey.

varkey = sy-mandt.

  • locking the tables............................

call function 'ENQUEUE_E_TABLE'

exporting

  • MODE_RSTABLE = 'E'

tabname = 'MARA'

varkey = varkey

  • X_TABNAME = ' '

  • X_VARKEY = ' '

  • _SCOPE = '2'

  • _WAIT = ' '

  • _COLLECT = 'X'

exceptions

foreign_lock = 1

system_failure = 2

others = 3

.

case sy-subrc.

when 1.

message i184(bctrain) with 'Foreignlock'.

when 2.

message i184(bctrain) with 'system failure'.

when 0.

message i184(bctrain) with 'success'.

when others.

message i184(bctrain) with 'others'.

endcase.

  • unlocking the table...............

call function 'DEQUEUE_E_TABLE'

exporting

  • MODE_RSTABLE = 'E'

tabname = 'MARA'

varkey = varkey

  • X_TABNAME = ' '

  • X_VARKEY = ' '

  • _SCOPE = '3'

  • _SYNCHRON = ' '

  • _COLLECT

Thanks.