‎2019 Apr 29 3:21 PM
Hi Experts,
I need urgently to implement Lock object to avoid changing of Customer ID ( customized Feld from customized DB) from different users and programs ...
So to achieve this I have processed as follow:
CALL FUNCTION 'ENQUEUE_ZTABLE ' EXPORTING
mode_Ztable = 'E'
mandt = sy-mandt
Customer ID = lv_Customer_ID
* X_Customer ID = ' '
* _SCOPE = '2'
* _WAIT = ' '
* _COLLECT = ' '
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
4- The object has shown in T.cde SM12.
5- at the same time in the second program I have called the data depend on the locked customer_ID :
update Ztable set Ztable~Customer_ID = new_customer_id
where Customer_ID = lv_Customer_ID
so why is not blocked and nothing sopped the process to say that this customer_id is already blocked by another user.
Even by deleting it will be deleted ...
your advice to achieve my requirement will be highly appreciated..
Best Regards
Khaled
‎2019 Apr 29 4:16 PM
‎2019 May 01 11:59 AM
Hi Raghu,
Thanks for your comment,
Could you pls provide an example or a Link for implementation of Lock objects
Best Regards
‎2019 Apr 29 4:20 PM
You very urgently need to read about how the locking concept works. It does not prevent changes to the database. It does not work the way you think it does.
‎2019 May 01 11:59 AM
Hi Matthew,
Thanks, it seems the Locking object will not serve my requirement directly, I used this call Function in the first/second Programs as well
CALL FUNCTION 'ENQUEUE_READ'
* EXPORTING
* GCLIENT = SY-MANDT
* GNAME = ' '
* GARG = ' '
* GUNAME = SY-UNAME
* LOCAL = ' '
* FAST = ' '
* GARGNOWC = ' '
* IMPORTING
* NUMBER =
* SUBRC =
TABLES
enq = lt_seqg3
* EXCEPTIONS
* COMMUNICATION_FAILURE = 1
* SYSTEM_FAILURE = 2
* OTHERS = 3
.
IF sy-subrc <> 0.
ENDIF.
then I will check the output table (lt_seqg3) first if she has any locked object which I need to call or delete then error msg. will be raised...
--- is there any better way to achieve this------
- Could you pls provide an example or a Link for implementation of Lock objects....
Best Regards.
‎2019 May 01 3:04 PM
‎2019 May 01 12:18 PM
Hello Khaled Al Sharbaji,
at first you have to create a lock object to prevent another user to change your table when you change it. It prevent more than one to change the field at same time.
Or if you want to lock the table you can use CALL FUNCTION 'ENQUEUE_E_TABLE'
Best regards
Ebrahim