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

Lock TABLES

Former Member
0 Likes
820

Hi,

May I know how do i lock WHOLE Table, without letting anyone to write data?

I have created lock entries called EZZVPAFINAL, but the same transaction still allow data to write into the table, as long as none records are same. How can I prevent totally none records are able to update the table, as long as there is one connection to the table.

CALL FUNCTION 'ENQUEUE_EZZVPAFINAL'

EXPORTING

MODE_ZVPAFINAL = 'E'

MANDT = SY-MANDT

ZVBELN = IT_ZVPA-ZVBELN

ZVKORG = IT_ZVPA-ZVKORG

ZVTWEG = IT_ZVPA-ZVTWEG

ZPOSNR = IT_ZVPA-ZPOSNR

ZMATNR = IT_ZVPA-ZMATNR

ZPLANT = IT_ZVPA-ZPLANT

  • X_ZVBELN = ' '

  • X_ZVKORG = ' '

  • X_ZVTWEG = ' '

  • X_ZPOSNR = ' '

  • X_ZMATNR = ' '

  • X_ZPLANT = ' '

  • _SCOPE = '2'

  • _WAIT = ' '

  • _COLLECT = ' '

EXCEPTIONS

FOREIGN_LOCK = 1

SYSTEM_FAILURE = 2

OTHERS = 3

.

CASE sy-subrc.

WHEN 0.

  • MESSAGE i888 WITH 'Enqueue successful'(001).

WHEN 1.

CALL TRANSACTION 'SM12'.

WHEN 2 OR 3.

ENDCASE.

5 REPLIES 5
Read only

Former Member
0 Likes
728

Hi Hui,

I guess SAP locks are created at application server level and not at database level.

Even though you create locks on the table, the other program should also try create a lock then only SAP throws an error, else it allows other program to update the data.

For Example:

1. prog1 locks data1

2. prog2 tries to lock data and update

3. prog3 tries to update data without lock.

In this scenarai, prog2 will get a error and prog3 will update the table.

So Ensure that whatever program tries to update the data should first acquire the lock.

Hope this helps you.

Thanks,

Arun

Read only

Former Member
0 Likes
728

Hi,

Do you mean check if there is lock on the table first before processing?

Read only

0 Likes
728

Hi Hui,

Yes that is a must.

Whenever you update a database table, you check whether it is locked or not.

Thanks,

Arun

Read only

0 Likes
728

JUST A QUESTION,

may i know how do i check in abap code whether there is a lock on the table?

is there any specific table to read?

Read only

0 Likes
728

LOCK OBJECTS

1)Go to se11 transaction.

2)Click on lock object radio button and give a lock object name starting with 'E'.For example 'ESAMPLE'.Click CREATE.

3)In the TABLE tab, you can give the table name for which you require a lock.In the LOCK PARAMETERS tab,you can give the table fields based on which the table should be locked.

4)Call a function module in your program ENQUEUE_lockobjectname to obtain a lock on the required table.In our example the FM will be ENQUEUE_ESAMPLE.

5)To release the lock on the table,call the function module DEQUEUE_lockobjectname.In our example the FM will be DEQUEUE_ESAMPLE.

Regards

Sreeni