2008 Jul 25 10:22 AM
Hi,
I want to lock a table completely during a program run.
I created a lock object with WRITE LOCK.
When I call the corresponding FM 'ENQUEUE_EZ...' with no key field specified, the table is not locked, because it still can be maintained via SM31.
When I use FM 'ENQUEUE_E_TABLEE' it works, but I would prefer to use a lock object, because you can lock more than one table at once...
Can anybody give help?
Thanks.
2008 Jul 25 10:27 AM
Hi,
GO to SE11-> create a Lock object ->
we have to start the Name of Object as EY or EZ then give the table name to be locked.
Then in the prpogram try to use the ENQUEUE and DEQUEUE to use this lock object.
Thanks & Regards,
Chandralekha.
2008 Jul 25 10:28 AM
2008 Jul 25 10:45 AM
Ok, this is how I try to lock the table:
CALL FUNCTION 'ENQUEUE_EZ_LH_TMPTABLES'
* EXPORTING
* MODE_ZMM_LH_LEGS_TMP = 'E'
* MODE_ZMM_LH_SRVCE_TMP = 'E'
* MANDT = SY-MANDT
* STATION =
* ROUTE =
* DEPDA =
* ACTDD =
* ACTTD =
* SEQNR =
* X_STATION = ' '
* X_ROUTE = ' '
* X_DEPDA = ' '
* X_ACTDD = ' '
* X_ACTTD = ' '
* X_SEQNR = ' '
* _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.
But unfortunately this doesn't work.
How can I achieve that the table for which I created a maintenance view cannot be changed during the program run?
For example, SM31 uses FM 'ENQUEUE_E_TABLEE' to lock the table when clicking the 'Maintain' button.
When I open SM31 in another session and try to maintain the same table, I get the message that this is not possible...
I want to have the same functionality...
2008 Jul 25 11:06 AM
Ok, I found out via SM12 that my table is locked. And if I run the same program in a second session, I get the FOREIGN_LOCK exception.
I just wondered why it is possible to maintain the table via SM31. But I will delete the maintenance view anyway, it's just for test purposes...
2008 Jul 25 11:26 AM
Hi,
In addition to locking FM u have to call one more FM.
check below logic.
Here whole table ZMARA is locked by FM ENQUEUE_EZMARA. U have to lock the view also by another FM VIEW_ENQUEUE.
Try to apply this logic in ur code. It is working fine.
It works in both ways i.e. U can't go in change mode in SM31 if it is locked by the program and in program u will get sy-subrc as non zero if it is locked by SM31.
So check and get back.
Pass appropriate view name.
CALL FUNCTION 'ENQUEUE_EZMARA'
* EXPORTING
* MODE_ZMARA = 'E'
* MANDT = SY-MANDT
* _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 'VIEW_ENQUEUE'
EXPORTING
* ACTION = 'E'
* ENQUEUE_MODE = 'S'
view_name = 'ZMARA'
* ENQUEUE_RANGE = ' '
* TABLES
* SELLIST =
EXCEPTIONS
CLIENT_REFERENCE = 1
FOREIGN_LOCK = 2
INVALID_ACTION = 3
INVALID_ENQUEUE_MODE = 4
SYSTEM_FAILURE = 5
TABLE_NOT_FOUND = 6
OTHERS = 7
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Thanks,
Vinod.
Edited by: Vinod Reddy Vemuru on Jul 25, 2008 3:58 PM