Tuesday, May 1, 2012

Lock Object

In a normal SAP screen. SAP will already have a lock on the screen. By lock we mean that when a user first clicks a prog, sap locks the prog for this user. When some other user tries to operate that same prog, then the user can not access the prog.
When u create a t code you have to put a lock for that t code. So to create a lock  go to se11 and click lock object. The name for lock object will always start with ez.
Then give a short description.
u should give the name of the table .
For ex the table name is zsc_data, the lock object name will be ezsc_data.

Now u should give whether it should be a write lock or read lock or exclusive lock.
Read lock means it will not display or let u change.
write lock means it will not let u change, it will display.
exclusive lock means it is exclusive lock.

Then go to the Lock parameter tab.
The mandt and the primary key will already be there, u want lock on any other field u should mention it.

When u create a lock there will be enque and deque object. Enque  is for locking and deque is for unlock.
In se38 u use call function

CALL FUNCTION 'ENQUEUE_EZSC_DATA1'
 EXPORTING
*   MODE_ZSC_DATA1       = 'E'
*   MANDT                = SY-MANDT
   MATNR                =
*   X_MATNR              = ' '
*   _SCOPE               = '2'
*   _WAIT                = ' '
*   _COLLECT             = ' '
 EXCEPTIONS
   FOREIGN_LOCK         = 1
   SYSTEM_FAILURE       = 2
   OTHERS               = 3
          .
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.


CALL FUNCTION 'DEQUEUE_EZSC_DATA1'
 EXPORTING
*   MODE_ZSC_DATA1       = 'E'
*   MANDT                = SY-MANDT
   MATNR                =
*   X_MATNR              = ' '
*   _SCOPE               = '3'
*   _SYNCHRON            = ' '
*   _COLLECT             = ' '
          .
If u want to view the lock object u need to go to sm12.
then enter the table name.and press f8.
if u want to delete the lock u can right click on it and release the lock. U can release the lock only when u have authorization to do that. U will have authorization release your own lock. But to release others lock u will need authorization.



No comments:

Post a Comment