2013 Jun 24 7:36 PM
Hi experts, I need to be able to lock a program based on a paramter on the selection screen so that only one user can edit at a time. Just like MM02, COr2, and XD02 have the ability to restrict one user to change the material number, process order and customer numbers.
This will be different than just chcking for a lock table.
Any help would be appreciated.
Thanks
Jayden
2013 Jun 25 4:23 AM
Hi Jayden,
I doubt i understand your question.
A program can only be edited by a single user at a time and that is standard behavior.
Having said that, if you want a single user to run any program at a time, then you can refer the code here - http://scn.sap.com/thread/1838118.
BR.
2013 Jun 25 4:46 AM
2013 Jun 25 5:23 AM
Your Lock Object should have the values which you wanted lock from other users.
As In MM02 selection-screen, locking parameter is client+material number.
Same way you should have your required fields in your locking parameter.
2013 Jun 25 5:30 AM
This won't be any different from checking a lock table. In fact, that is your solution.
2013 Jun 25 5:47 AM
Hi,
The program can be edited ( as in change code ) only by single user at a time. But if you meant that only one user can execute the program at any given time you can achieve the same by setting parameters say like a flag field in Ztable is set via the selection screen checkbox to state that the program is being used.
The code should clear it at the end of program. Then you can always have a list to refer to via any program that you want checked before execution
Cheers,
Arindam
2013 Jun 25 1:59 PM
Sorry, I was referring to the execution of the program, not the editing of the program in se38 or se80.
In using a LOCK OBJECT what happens if the connection to SAP is lost or the program never finishes?
My worries is with a hung session. Would assigning a value to a memory ID work? Then FREE this value once the program is finished?
Arindam, this is the reason that I don't want to create a value and put in a ztable.
2013 Jun 25 2:00 PM
2013 Jun 26 7:36 AM
2013 Jun 25 2:11 PM
Hi Jayden,
As Pavan and others said just create a lock object in SE11 specifying the table name that needs to edited by one user and then call the function module "ENQUEUE_yourlockobject" in program and at the end dequeue.
Srikanth.
2013 Jun 25 3:17 PM
Can this be done by value? For example, when a user is changing a material in MM02, MARA is locked, only that Material Number is locked.
Thanks
Jayden
2013 Jun 25 5:36 PM
Hi Jayden,
You are on the right track, and you've been given good advice so far.
For example if you search the lock objects available in SE11 for "MARA" in the description, you may find lock object EMMARAE.
That has lock parameters of MANDT and MATNR, so you can limit to a single material.
You can lock more than 1 table with a lock object if that is your requirement and the right foreign keys are avialable.
If you are worried about old locks causing problems, just check out transaction SM12. In fact, why not write a little prototype and check out SM12 while running your code through the debugger.
Hope this helps, and watch out for deadly embraces
Stuart.
2013 Jun 26 8:09 AM
You could read some documentation like The SAP Lock Concept, and its Example Program: SAP Locking. (after a brief search on google with option site:help.sap.com)
Regards,
Raymond
2013 Jun 26 8:30 AM
Dear Jaydan,
You can create Lock object using T-code SE11 , Naming convention start with 'E' e.g. Exxx (where xxx is a table name), then say create. Then 'table tab' please select correct locking mode that is either 'Read' or 'Write' and under 'lock parameter tab' you select which column are required to be lock.
Once you create and activate automatically two functions modules are getting created like
ENQUEUE_Exxx ( To lock)
DEQUEUE_Exxx ( To unlock)
and use above function modules for locking the tables. Also you can use secondary tables for locking purpose.
Regards
Vaman Kamat