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 Object

Former Member
0 Likes
604

Hi Experts,

I have athe following requirement kindly help me to solve.

If 2 users are trying to use the same milestone at the same time in different Sale order and when the user 1 has saved the particular milestone and when the 2nd user tries to save it , i should pop up an error that the milestone is already used.

The issue is i dont know where to get the milestone number as it will not be updated in any table before the SO is saved.

I should pop up the error before i save the particular SO.

Could any one provide me a solution on how to get the milestone number or any solution is there.

Kindly help.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
510

Hi,

You can create a custom table called ZCHECK_LOCK with three fields 'MILESTONE_NO', 'LOCKED' and 'USER', where MILESTONE_NO would be of type of the milestone number you are using, 'LOCKED' would be of type CHAR1 and USER would be of type SY_UNAME.

Now say you are user 1 and you have entered the transaction and using a milestone number, then in the corresponding PAI of the screen where the milestone number is being used, make a select on the table ZCHECK_LOCK with the milestone number that you are using. If sy-subrc is 4, then insert a record in this table where MILESTONE_NO is the milestone number you are using and LOCKED = 'X', user name would be your ID.

Now another user say user2 enters the transaction. He enters the same milestone number that you are using. As soon as he enters, the PAI event is triggered, where a select is being made on table ZCHECK_LOCK. The sy-subrc returned is 0 which means that someone is already using this number. So a message would be popped up stating that 'Milestone number 'XXXXXX' is locked under user 'YYYY'.

Now you save the sales order or come out of it, then you need to delete the entry from ZCHECK_LOCK, as you job is done and the number is free to be used by another user. So now after you have left the transaction, if user 2 again tries entering the number, he would get sy-subrc 4, and a record would be created under his ID. He would be able to use it and thereby block teh number for others.

Hope this helps!

2 REPLIES 2
Read only

Former Member
0 Likes
511

Hi,

You can create a custom table called ZCHECK_LOCK with three fields 'MILESTONE_NO', 'LOCKED' and 'USER', where MILESTONE_NO would be of type of the milestone number you are using, 'LOCKED' would be of type CHAR1 and USER would be of type SY_UNAME.

Now say you are user 1 and you have entered the transaction and using a milestone number, then in the corresponding PAI of the screen where the milestone number is being used, make a select on the table ZCHECK_LOCK with the milestone number that you are using. If sy-subrc is 4, then insert a record in this table where MILESTONE_NO is the milestone number you are using and LOCKED = 'X', user name would be your ID.

Now another user say user2 enters the transaction. He enters the same milestone number that you are using. As soon as he enters, the PAI event is triggered, where a select is being made on table ZCHECK_LOCK. The sy-subrc returned is 0 which means that someone is already using this number. So a message would be popped up stating that 'Milestone number 'XXXXXX' is locked under user 'YYYY'.

Now you save the sales order or come out of it, then you need to delete the entry from ZCHECK_LOCK, as you job is done and the number is free to be used by another user. So now after you have left the transaction, if user 2 again tries entering the number, he would get sy-subrc 4, and a record would be created under his ID. He would be able to use it and thereby block teh number for others.

Hope this helps!

Read only

Former Member
0 Likes
510

Hi,

What is the table that you will be updating with the details. If you are using a custom table, then please go for a lock object. If any update happens for that table, it automatically throws the error message. It does not require any validation. If it is an standard table, please check if there is an lock object already existing. If so, then make use of that. Hope this helps.

Regards

Senthil.