2009 Aug 18 6:48 AM
Hi,
I am aware that we can lock an entire table using locking.
However i was wondering how we can use lock objects to lock specific Fields of a table for specfic records
Hi Sarvesh,
Yes, its possible to lock the table at record level.
You can lock individual records based on the Key Fields only.
suppose if you have created a lock object EZMARA, then two FMs will be created, one for locking the table at record level and one for unlocking it,
FMs:
ENQUEUE_EZMARA
DEQUEUE_EZMARA
to lock the table at record level you need to call ENQUEUE_EZMARA and assign the keyfield value ( for which record you need to lock)
Pls dont forget to unlock the record one updation is done.
Infact this is a good programming practice in Database systems.
Rgds,
Sripal
2009 Aug 18 6:59 AM
Hi,
Yes. You can lock individual records based on the Key Fields. Use the FM: ENQUEUE_E_TABLE.
In the parameter VARKEY, concatenate your Key Field values and pass it to the above FM. So only the particular record will be locked.
Parameters:
TABNAME
VARKEY
Regards,
Chathia.
2009 Aug 18 10:44 AM
Hi Sarvesh,
Yes, its possible to lock the table at record level.
You can lock individual records based on the Key Fields only.
suppose if you have created a lock object EZMARA, then two FMs will be created, one for locking the table at record level and one for unlocking it,
FMs:
ENQUEUE_EZMARA
DEQUEUE_EZMARA
to lock the table at record level you need to call ENQUEUE_EZMARA and assign the keyfield value ( for which record you need to lock)
Pls dont forget to unlock the record one updation is done.
Infact this is a good programming practice in Database systems.
Rgds,
Sripal
2009 Aug 18 2:01 PM
>
> However i was wondering how we can use lock objects to lock specific Fields of a table for specfic records
If I understand correctly, the original poster wants to lock specific fields.
Sarvesh, keep in mind that:
- A lock using SAP lock objects only works if others updating the table also always call the lock function. That is, if this is a Z table you have to make sure you call the lock function before each update (and unlock afterwards).
- If you do this with a specific Z lock object before you update the fields you want (but not before other different fields are updated) then you should get what you want.
- If what you want is actually to lock specific records then forget what I just said and read the answers above.
2009 Aug 18 3:01 PM
Hi Sarvesh,
It is possible to lock a database table at a record (row) level but not at a field level. For example you can lock all the lines of a sales order in table VBAP by specifying the client (MANDT) and order number (VBELN) in function module ENQUEUE_EMVBAP. However it is not possible to lock table for say a specified material number. Locking is always possible either for the entire table or for a combination of the primary key.
Certain tables have lock objects that have lock modules. For example VBAP has a lock object EMVBAP. Lock object EMVBAP
has lock modules ENQUEUE_EMVBAP for locking and DEQUEUE_EMVBAP for unlocking locked records in table VBAP. Not all database tables have lock objects.
When a table does not have lock objects assigned to it you can use the generic function module ENQUEUE_E_TABLEE and DEQUEUE_E_TABLEE to do the same thing. Function module ENQUEUE_E_TABLEE has a parameter VARKEY. You need to pass a concatenation of the fields values (in the primary key) that you want to lock. for example if you order number is '9999999999' and you client is '010' then VARKEY = '0109999999999'. If sales oder '9999999999' has hundred line items all the line items will get locked. If I want to just lock line item '000030' then VARKEY = '0109999999999000030'. Make sure you add the leading zeros for VBELN and POSNR while constructing the VARKEY parameter. I am not sure if you can lock records using ''. For example if I want to lock all records in VBAP where POSNR is '000030', I am not sure if this can be done by say VARKEY = '010000030'.
Another thing that you need to keep in mind with locking records is that you want to make sure that you do not create too many locks. I think there is a limit on the number of records you can lock at one time.
Let me know if this helps.
Regards,
Mark
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |