2006 Nov 29 10:59 AM
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
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
2006 Nov 29 11:02 AM
2006 Nov 29 11:03 AM
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
2006 Nov 29 11:06 AM
2006 Nov 29 11:14 AM
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
2006 Nov 29 11:21 AM
Hi,
U have handle the Exceptions explicitely.
Hope this helps.
2006 Nov 29 11:22 AM
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
2006 Nov 29 11:27 AM
i am using the same userid but different sessions.
and i want to restrict same user to modify it in another session
2006 Nov 29 11:34 AM
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..
2006 Nov 29 11:34 AM
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
2006 Nov 29 3:27 PM
Hi Sonika,
Check this link
http://help.sap.com/saphelp_nw04s/helpdata/en/7b/f9813712f7434be10000009b38f8cf/frameset.htm
Regards,
Kinshuk
2006 Nov 30 8:07 AM
Hi,
Check for authorization object along with lock objects
Regards
Yamini
2006 Nov 30 10:55 AM
Hello,
Look for DEQUEUE_* and ENQUEUE_* FM's in se37 and search in the SDN for seeing how to use them
Regards,
Shehryar Dahar
| User | Count |
|---|---|
| 6 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |