‎2006 Sep 26 8:22 AM
I have created a lock object,but it is not clear whether it locks the database table or just the parameters of the tables which are mentioned.
Can someone explain me clearly what are the objects which can be locked by creating Lock objects?
‎2006 Sep 26 8:25 AM
Hi
You can lock whole table or only single/some records: it depends on how you've define the object.
Anyway it's only logic lock and you have to raise it by FM.
If you have calles your object E<......>, the system has generated the fms:
ENQUEUE_E<......> -
> To lock
DEQUEUE_E<......> -
> To Unlock
U have to call these fms to active or deactive the lock
Max
‎2006 Sep 26 8:26 AM
hi anurita,
chk this.
Lock objects are used to lock the database table while making the modifications on the database table.
you can create your own lock objects using SE11.
if you create lock objects on any table system will create two function modules.
1.ENQUEUE....
2.DEQUEUE.....
first one is used to lock the table
second one used to removing lock on the table.
*----
lock Table
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
tabname = table_name
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
*----
Unlock Table
CALL FUNCTION 'DEQUEUE_E_TABLE'
EXPORTING
tabname = table_name
check this link :
http://help.sap.com/saphelp_40b/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
rgds
anver
if helped mark points
‎2006 Sep 26 8:27 AM
These types of objects are used for locking the access to database records in table. This mechanism is used to enforce data integrity that is two users cannot update the same data at the same time. With lock objects you can lock table-field or whole table.
In a system where many users can access the same data, it becomes necessary to control the access to the data. In R/3 system this access control is built-in on database tables. Developers can also lock objects over table records.
To lock an object you need to call standard functions, which are automatically generated while defining the lock object in ABAP/4 dictionary. This locking system is independent of the locking mechanism used by the R/3 system. This mechanism also defines LUW i.e. Logical Unit of Work. Whenever an object is locked, either by in built locking mechanism or by function modules, it creates corresponding entry in global system table i.e. table is locked. The system automatically releases the lock at the end of transaction. The LUW starts when a lock entry is created in the system table and ends when the lock is released.
Creating Lock Objects
Lock object is an aggregated dictionary object and can be defined by using the following steps:
o From initial data dictionary screen, enter the name for the object, Click Lock object radiobutton and then click on Create. The system displays a dialog box for Maintain Lock Objects screen
o Enter short text as usual and the name for primary table.
-Save
-Select Tables option
From this screen you can:
Select secondary tables, if any, linked by foreign key relationship.
Fields for the lock objects. This option allows you to select fields for objects (R/3 system allows locking up to record level). Lock object argument are not selected by user but are imposed by the system and includes all the primary keys for the table.
1) Exclusive lock: The locked data can only be displayed or edited by a single user. A request for another exclusive lock or for a shared lock is rejected.
2) Shared lock: More than one user can access the locked data at the same time in display mode. A request for another shared lock is accepted, even if it comes from another user. An exclusive lock is rejected.
3) Exclusive but not cumulative: Exclusive locks can be requested several times from the same transaction and are processed successively. In contrast, exclusive but not cumulative locks can be called only once from the same transaction. All other lock requests are rejected.
Also, last but not the least, locking the object is logical (locking with any enqueue ) .so, you have to use the lock object while trying to access from second program .
complete refrence refer...
http://help.sap.com/saphelp_47x200/helpdata/en/a2/3547360f2ea61fe10000009b38f839/frameset.htm
‎2006 Sep 26 8:30 AM
HI,
Add the following code in-order to create the table lock. This function module must be called before any
update takes place. If a lock has already been taken out it will display the appropriate message.
CALL FUNCTION 'ENQUEUE_EZ_ZTABLENAME'
EXPORTING
mode_ZTABLENAME = 'E'
mandt = sy-mandt
KEYFIELD1 = "Value
KEYFIELD2 = "Value
KEYFIELD3 = "Value
...
* X_KEYFIELD1 = ' '
* X_KEYFIELD2 = ' '
* X_KEYFIELD3 = ' '
...
* _SCOPE = '2'
* _WAIT = ' '
* _COLLECT = ' '
* If exceptions are not used, message is displayed within FM
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Retrieve message displayed within Function Module
message id sy-msgid
type 'I'
number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXIT.
ENDIF.
See the below SAP Help screen with example about the LOCK objects
http://help.sap.com/saphelp_nw2004s/helpdata/en/af/22ab01dd0b11d1952000a0c929b3c3/content.htm
Regards
Sudheer
‎2006 Sep 26 8:39 AM
Hi,
When you create A Lock Object, in the third tabstrip button, Lock Parameters, u get the list of fields as lock parameters, they are nothing but your Primary Key fields, the concept here is if you Lock the Primary Key fields it means you have locked the entire table from updation, so without primary key u cannot enter any values into the table.
Regards:-
Santosh.D
‎2006 Sep 26 8:47 AM
hi,
i want to tell you in simple language,
for example,when you are working with a program in SE38,
if any others opens that program,that will be in display mode for them,right,
like,that using lock object,when you are editing a table/record,
you can restrict the access to that database (table/record) for users,
to avoid inconsistencies in the display,
i hope you got it,
kcc
‎2006 Sep 26 10:21 AM
hi,
You have to mention the lock object name for that table.
We can even lock a complete table or a record of it based on the parameters given.
You can create a lock on a object of SAP thorugh transaction SE11 and enter any meaningful name start with EZ Example EZTEST_LOCK.
When you create a lock object System automatically creat two function module.
1. ENQUEUE_<Lockobject name>. to insert the object in a queue.
2. DEQUEUE_<Lockobject name>. To remove the object is being queued through above FM.
Regards,
Sailaja.