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

Locking a Program for only 1 user in edit mode

Former Member
0 Likes
3,829

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

13 REPLIES 13
Read only

Former Member
0 Likes
2,620

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.

Read only

Former Member
0 Likes
2,620

Hi Jayden,

You can achieve by using LOCK OBJECT.

Thanks

Pavan

Read only

Former Member
0 Likes
2,620

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.

Read only

matt
Active Contributor
0 Likes
2,620

This won't be any different from checking a lock table. In fact, that is your solution.

Read only

arindam_m
Active Contributor
0 Likes
2,620

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

Read only

Former Member
0 Likes
2,620

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. 

Read only

Former Member
0 Likes
2,620

I almost forgot.  THanks for ALL of the replys

Read only

0 Likes
2,620

Hi Jayden,

Please see the sample code at

http://scn.sap.com/thread/1838118.

BR.

Read only

former_member213275
Contributor
0 Likes
2,620

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.

Read only

Former Member
0 Likes
2,618

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

Read only

0 Likes
2,618

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.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
2,618

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

Read only

Former Member
0 Likes
2,618

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