ā2013 Jun 05 8:26 AM
Hi ,
In a program I am pulling out data from 3 tables and creating an Internal table.In this internal table I have a field trans.date which is nothing but the current date. So with this internal table I will create entries in custom created database table .So daily it will create entries with transfer date as sy-datum for different plan.location say PL1 ,PL2 like this.
So while updating the database table I am always creating a new entry in tables based on daily data available.I am not modifying any entry in the table.
My question here is do i have to enqueue and dequeue the table before updating it or not needed in this case because I am not modifying any entries .I am always creating a new entry for different Planning locations.
What will happen say for location PL1 and PL2 I am running this program in background parallely .Both will try creating entries in the table X will they lock each other ??
Kindly advise.
Thanks
ā2013 Jun 05 9:26 AM
Hi Suganth,
Whether you are inserting or updating database table it's a good practice to use lock objects to avoid the inconsistencies.
ā2013 Jun 05 9:26 AM
Hi Suganth,
Whether you are inserting or updating database table it's a good practice to use lock objects to avoid the inconsistencies.
ā2013 Jun 05 9:36 AM
Hi Suganth,
It is not the case for you where you can relate your question.
You can update or Insert the DB Table as you wish. I Mean you can Either ENQUEUE the Table before Inserting the Records or you Can just use INSERT Statement.
The Only thing that depends here is the Primary Key. If your record only will have a new Primary key everytime when you INSERT records into your DB Table then you dont need to Lock the Table to Update(ENQUEUE is not needed). If you dont have full key then Lock is Mandatory.
But for a good practice we generally enqueue before DB Updates as Kaushalya perera Said.
Anyhow it doesnt impact anyway on your performance yo call the ENQUEUE and DEQUEUE FMs before you update
Hope this helps
ā2013 Jun 05 9:37 AM
Hi Suganth,
Since you are only inserting entries into this table, no write lock is required.
But if do not want some other program to read this table while you are updating it, you can impose a read lock. If you ask me, I would say that its not required.
Thanks,
Sreekanth
ā2013 Jun 05 9:37 AM
Hey,
Inserting a new record in table is also kind of modification in table. It is safe and best practice to take a lock before modifying table.
I would suggest you to use ENQUEUE and DEQUEUE rather than directly inserting record in table.
ā2013 Jun 05 9:59 AM
Hi,
Anyways its a background job.
if you are running in non working hours then no need of applying any lock.
you can schedule your job before and after working hours.
so you will not come across accessing table at the same time.
I have did this for my client.
Regards
Tejas
ā2013 Jun 05 11:00 AM
Hi,
As told above best practice is to create Z Function Modules for Enqueue and Dequeue via T-code SE11 for your Custom Table.
Now whether you are Updating or Creating if two programs are run at the same time and they try to access the Z table simultaneously a deadlock will occur and it will error out saying entries are locked by other program or may be userid.
Go for Locks, see this for help https://scn.sap.com/thread/846741
BR,
Ankit.
ā2013 Jun 05 1:01 PM
Locking in not required if you are inserting records in a table with unique primary key.. if the same entry will come again it will be ignored..
locking is required when the same entry can be modified by multiple persons at the same time..
hope it solves your query