2013 Mar 08 7:18 AM
Hello,
We have created a custom transaction and custom tables to update the changes. Everytime a user creates a new entry in the transaction a new request number is updated in the custom table.
When two users at a time login to create a new request in the transaction and press the save button, then same request number is created for both of them and the system is not incrementing the request numbers.
TO explain it simple, we need it to be like a sale order. Any no. of users can login to VA01 and on pressing save simultaneously, the system
increments the sale order number by one. I would like a similar lock on this as well.
Can some one give me an idea pls?
2013 Mar 08 9:13 AM
Use lock on Custom tables before updating in program. use ENQUEUE_E_TABLE to lock before update and DEQUEUE_E_TABLE to unlock after update.
Hope this helps.
-SS-
2013 Mar 08 9:13 AM
Use lock on Custom tables before updating in program. use ENQUEUE_E_TABLE to lock before update and DEQUEUE_E_TABLE to unlock after update.
Hope this helps.
-SS-
2013 Mar 08 9:23 AM
Hi Prem,
You can just get the request number as you are getting now,
but when updating check the request number again.
if the request number that needs to be entered is same as you have on the screen lock the table and update the record.
else
update the screen with the new request number and flash a message that the number has been updated/modifies with respect to the table entry.
2013 Mar 08 9:24 AM
Hi,
you must use the range number : trans. SNRO
and after used the function : NUMBER_GET_NEXT ...
you will find a lot of example, codes, ... with the function name
Regards
Fred
2013 Mar 08 9:30 AM
You may not require actually a lock here but yes create one with your custom table to insure an user wont be able to modify the same record than another one;
What you require is a range number :
Also use search tool on range number.
Regards,
Raymond
2013 Mar 08 9:34 AM
Hi Prem,
Could u pls tell me how you create the New request Number .Please provide ur code.
I think u have to do this after Creating the Number Range in TCODE - SNRO than u have to use the FM - NUMBER_GET_NEXT to get the next Number.
i think it will solve ur problem.
Thanks
tarak
2013 Mar 08 10:04 AM
2013 Mar 08 10:24 AM
Hi,
In case you're not already doing so, to manage the number increment for your primary key you'd best use a Number Range Object.
So go to TCODE SNRO, create a NO Range Object and an Interval.
Before a user saves the data in your Z table, call FM NUMBER_GET_NEXT. This should not fail in case two users hit SAVE button at the same time.
Then as to the locking issue, you should first create a lock object in tcode SE11 for your table. Let's call it EZTEST. After you have created the lock object, SAP generates 2 FM: ENQUEUE_EZTEST and DEQUEUE_EZTEST. By using these 2 FM you can set a lock and unset it on your Z table with specific primary key(s) value(s).
In order to check if a certain lock has been set on your Z table use FM: ENQUEUE_READ.
There's probably more to say on this subject, but perhaps the info I gave you will give you a first glance on what you should/can do.
Br,
Andrei
2013 Mar 10 3:12 PM
Thanks to all for your replies.
If locking and unlocking is the way to fix this then i will follow the same. I do not maintain any number range,just increment the request number by one from the database.
@ Andrei - "Before a user saves the data in your Z table, call FM NUMBER_GET_NEXT. This should not fail in case two users hit SAVE button at the same time."
Do you mean to say then by using this FM i do not need to lock and unlock the table ?
Thanks.
2013 Mar 11 11:08 AM
Hi,
Kinda yes. Correct me if i'm wrong, but you don't actually need to lock the table in Insert because you're only problem is the uniqueness of the primary key.
By using Number Ranges and the above mentioned FM you can guarantee that two users will never get the same primary key value and that, if I'm not mistaken, solves your problem.
-
Andrei