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

Concurrency when inserting in the same table

former_member254358
Participant
0 Likes
1,151

Hi,

I have a report used by several users and in this record there is a sentence to insert in a z table. My question is, what happens whether two or more users are inserting records in that table at the same time?  There is a concurrency problem, isn't there?

How does SAP manage this issue? or, what must I do in this case?

Thanks in advance.

Regards.

5 REPLIES 5
Read only

Former Member
0 Likes
980

Hi David,

Please search about Enqueue and Dequeue funtion modules.

There is a Lock Mechanism that you can put in place to avoid data inconsistency issues.

There is a lot of information on SCN/web.

Please get back for specific doubts.

Regards,

DN.

Read only

0 Likes
980

Thanks for your reply and your help.

Each time that a user run the report only one record is inserted in the z table. My doubt is what could happen if two users try to insert at the same time? Have I to manage this one or not?

Regards.

Read only

Former Member
0 Likes
980

David,

Place a lock before inserting data into table with specified key. Do, insert operation and then release the lock on the specified key table.

In case, more than one user tries to insert same data with same key, then only one user able to insert data and another will get lock.

Read only

ramakrishnappa
Active Contributor
0 Likes
980

Hi David,

As SAP applications are accessed by many end users at same time, SAP has concept called LOCKING of particular tables involved in the transaction.

You can achieve your requirement as below


  • Go to t-code SE11, and create a lock object for your Ztable
  • Now, system create 2 function modules - 1 for locking ENQUEUE_* & other for un-locking DEQUEUE_*  ( search for function module in SE37 )
  • Before saving data to ZTABLE, call function module ENQUEUE_* to lock the table for writing data, if locking fails, means there is somebody already working on it, hence you can display error message
  • After Save action, you can unlock the table by using FM ... DEQUEUE_*

Note: you can lock and unlock event during DISPLAY/CHANGE mode if your requirement requires.

Hope this helps you.

Regards,

Rama