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

Regarding lock object

former_member632991
Active Contributor
0 Likes
1,442

Hi,

i have a transaction which i want to lock for another user to modify if someone else is editing that. How can i use lock objects in that.

Pls explain with example

Regards,

Sonika

12 REPLIES 12
Read only

Former Member
Read only

Former Member
0 Likes
1,341

Hi Sonika,

You can use any one the below lockobject to lock another transaction. (Use lock mode as 'E' exclusive)

<b>ESSCAL

ESSOSTC

ESTERM</b>

The sample code will be

* Locking the transaction code -MM01
 CALL FUNCTION 'ENQUEUE_ESTERM'
  EXPORTING
    MODE_TSTC            = 'E'
    TCODE                = 'MM01'
  EXCEPTIONS
    FOREIGN_LOCK         = 1
    SYSTEM_FAILURE       = 2
    OTHERS               = 3.
 IF sy-subrc <> 0.
Message 'Error in lockig' type 'E'.
 ENDIF.
 
* Write the code with respective to MM01. 
 
* Unlocking the transaction code -MM01 
 CALL FUNCTION 'DEQUEUE_ESTERM'
  EXPORTING
    MODE_TSTC       = 'E'
    TCODE           = 'MM01'
    X_TCODE         = ' '
    _SCOPE          = '3'
    _SYNCHRON       = ' '
    _COLLECT        = ' '.

If helps plz reward points.

Regards

Bhupal Reddy

Read only

0 Likes
1,341

Hi Sonika,

look for "enqueue" & "dequeue" FM through the forum .

Hope this helps,

Erwan

Read only

0 Likes
1,341

actully, i am using in a Z-program. I am using enquee_(lock_object) function module to lock object. And i have seen in sm12 that object is locked. but i can still make changes. Please help

will error msg print automatically or we have to create it.

Message was edited by:

Sonika Ahuja

Read only

0 Likes
1,341

Hi,

U have handle the Exceptions explicitely.

Hope this helps.

Read only

0 Likes
1,341

Hi Sonika,

You might checking worngly. i.e. check with other useid it will works fine. for your user it won't work.

Regards

Bhupal Reddy

Read only

0 Likes
1,341

i am using the same userid but different sessions.

and i want to restrict same user to modify it in another session

Read only

0 Likes
1,341

Hi,

U want to lock the same user is it?

So in that case if the user has autorization to change that object the lock will not work..

Read only

0 Likes
1,341

Hi Sonika,

Use optimistic locking mechanism. It will helps to you.

The following will works fine.

  • Locking the transaction code -MM01 (optimistic)

CALL FUNCTION 'ENQUEUE_ESTERM'

EXPORTING

MODE_TSTC = 'O'

TCODE = 'MM01'

EXCEPTIONS

FOREIGN_LOCK = 1

SYSTEM_FAILURE = 2

OTHERS = 3.

IF sy-subrc <> 0.

Message 'Error in lockig' type 'E'.

ENDIF.

  • Locking the transaction code -MM01 (After this FM - 'O' will be converted to 'E')

CALL FUNCTION 'ENQUEUE_ESTERM'

EXPORTING

MODE_TSTC = 'R'

TCODE = 'MM01'

EXCEPTIONS

FOREIGN_LOCK = 1

SYSTEM_FAILURE = 2

OTHERS = 3.

IF sy-subrc <> 0.

Message 'Error in lockig' type 'E'.

ENDIF.

  • Write the code with respective to MM01.

  • Unlocking the transaction code -MM01

CALL FUNCTION 'DEQUEUE_ESTERM'

EXPORTING

MODE_TSTC = 'E'

TCODE = 'MM01'

X_TCODE = ' '

_SCOPE = '3'

_SYNCHRON = ' '

_COLLECT = ' '.

The above code used for locking the transaction code in program. If you want to do through screen, go to SM01 -> lock the transaction.

If help plz reward points.

Regards

Bhupal Reddy

Read only

Former Member
0 Likes
1,341
Read only

Former Member
0 Likes
1,341

Hi,

Check for authorization object along with lock objects

Regards

Yamini

Read only

Former Member
0 Likes
1,341

Hello,

Look for DEQUEUE_* and ENQUEUE_* FM's in se37 and search in the SDN for seeing how to use them

Regards,

Shehryar Dahar