cancel
Showing results for 
Search instead for 
Did you mean: 

Lock table for reads...

Former Member
0 Kudos

Hi,

I try to look a table for update.

During update I get ZERO rows in SE16 for table ZRPICE_TAB. Look at NOTE1.

sptab-TABNAME = 'ZPRICE_TAB '.

sptab-VARKEY = SY-MANDT.

call function 'ENQUEUE_E_TABLE'

EXPORTING

TABNAME = sptab-TABNAME

VARKEY = sptab-VARKEY

EXCEPTIONS

FOREIGN_LOCK = 1

SYSTEM_FAILURE = 2

OTHERS = 3

.

delete from ZPRICE_TAB. " empty this table " NOTE1

insert ZPRICE_TAB from table i_priceZPR13100.

insert ZPRICE_TAB from table i_priceZPR14100.

call function 'DEQUEUE_E_TABLE'

EXPORTING

TABNAME = sptab-TABNAME

VARKEY = sptab-VARKEY.

NOTE1: After this statement I get zero rows from SE16.

This should not be the case. There must always be data in the table.

I want to look the table for READ:s as well I belive...

Any pointers ?

//Martin

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi, Christian Finkbeiner say is right, actually the ENQUEUE/DEQUEUE mechansim doesn't have any force restriction to avoid other applications to populate the same table or same record, it doesn't like the DB lock, please aware.

That means if you want to keep exclusive access the table, all the application which want to populate the same table should coordinate with each other.

Check the return value of the ENQUEUE, and have a try to insert again when close SE16.

I guess the problem is not in SE16. Because when I populate a customize table in SE16, I can't see the lock entry in SM12.

Thanks

Message was edited by: zhenglin gu

Former Member
0 Kudos

Hi,

Other programing languages has support for something called trasactions. A transaction is a unit of work that either goes OK or Error/Rolled back.

Looks something like this:

Begin Transaction

delete from ZPRICE_TAB. " empty this table " NOTE1

insert ZPRICE_TAB from table i_priceZPR13100.

insert ZPRICE_TAB from table i_priceZPR14100.

end transaction

if transaction = 'OK' then

COMMIT

else

ROLLBACK

end if

This type of transaction make sure that if the last statement (insert....) goes wrong .....everything is rolled back (as it was from the beginning.)

If this isn't the case we can end up having a empty table!

//Martin

Former Member
0 Kudos

ABAP has the same functionality - the SAP logical unit of work (LUW). In your case, code something like:


delete from ZPRICE_TAB. " empty this table " NOTE1
if sy-subrc = 0.
  insert ZPRICE_TAB from table i_priceZPR13100.
  if sy-subrc = 0.
    insert ZPRICE_TAB from table i_priceZPR14100.
  endif.
endif.
  if sy-subrc <> 0.
rollback work.
endif.

A commit will take place automatically when the program finishes.

Rob

Answers (2)

Answers (2)

Former Member
andreas_mann3
Active Contributor
0 Kudos

Lock table for reads...

i think that's not possible.

What's about reports with dynamic selection ?

regards Andreas

eddy_declercq
Active Contributor
ChristianFi
Active Participant
0 Kudos

Since SAP provides locks on a logical not on a physical layer the answer is yes it is possible but you have to take care by yourself that before the data is read the lock objects are considered (via the enqueue, dequeue functions)

This however does not mean that programs will automatically take care of (like SE16).

Christian