Lock object using RFC
Hi,
in standard transaction I lock an object in an other system using RFC lock(enqueue function) but when I exit from transaction the object in other system is automatically unlocked without using the dequeue function.
Is It the correct behaviour?
Thanks,
Max Boscolo
Hi
Lock objects are use in SAP to avoid the inconsistancy at the time of data is being insert/change into database.
SAP Provide three type of Lock objects.
- Read Lock(Shared Locked)
protects read access to an object. The read lock allows other transactions read access but not write access to
the locked area of the table
- Write Lock(exclusive lock)
protects write access to an object. The write lock allows other transactions neither read nor write access to
the locked area of the table.
- Enhanced write lock (exclusive lock without cumulating)
works like a write lock except that the enhanced write lock also protects from further accesses from the
same transaction.
You can create a lock on a object of SAP thorugh transaction SE11 and enter any meaningful name start with EZ Example EZTEST_LOCK.
Use: you can see in almost all transaction when you are open an object in Change mode SAP could not allow to any other user to open the same object in change mode.
Example: in HR when we are enter a personal number in master data maintainance screen SAP can't allow to any other user to use same personal number for changes.
Technicaly:
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.
You have to use these function module in your program.
check this link for example.
http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
tables:vbak.
call function 'ENQUEUE_EZLOCK3'
exporting
mode_vbak = 'E'
mandt = sy-mandt
vbeln = vbak-vbeln
X_VBELN = ' '
_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.
Normally ABAPers will create the Lock objects, because we know when to lock and how to lock and where to lock the Object then after completing our updations we unlock the Objects in the Tables
http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
purpose: If multiple user try to access a database object, inconsistency may occer. To avoid that inconsistency and to let multiple user give the accessibility of the database objects the locking mechanism is used.
Steps: first we create a loc object in se11 . Suppose for a table mara. It will create two functional module.:
1. enque_lockobject
1. deque_lockobject
before updating any table first we lock the table by calling enque_lockobject fm and then after updating we release the lock by deque_lockobject.
http://help.sap.com/saphelp_nw04/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
GO TO SE11
Select the radio button "Lock object"..
Give the name starts with EZ or EY..
Example: EYTEST
Press Create button..
Give the short description..
Example: Lock object for table ZTABLE..
In the tables tab..Give the table name..
Example: ZTABLE
Save and generate..
Your lock object is now created..You can see the LOCK MODULES..
In the menu ..GOTO -> LOCK MODULES..There you can see the ENQUEUE and DEQUEUE function
Lock objects:
http://www.sap-img.com/abap/type-and-uses-of-lock-objects-in-sap.htm
http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
Match Code Objects:
http://help.sap.com/saphelp_nw2004s/helpdata/en/41/f6b237fec48c67e10000009b38f8cf/content.htm
http://searchsap.techtarget.com/tip/0,289483,sid21_gci553386,00.html
See this link:
http://www.sap-img.com/abap/type-and-uses-of-lock-objects-in-sap.htm
Check these links -
lock objects
Lock Objects
Lock Objects
Regards
Anji
Similar Messages
-
Locking objects across RFC calls
Hi All,
I am developing a business application using SAP UI5 and the NetWeaver Service Gateway in an embedded scenario. I have RFCs build for the backend interaction. As per my knowledge, each RFC is considered as a separate transaction and the user is logged on and off as the RFC is processed. This removes the lock on the object that I need to be sustained till the next RFC call. Unlocking the object exposes it to possible editing by other users which is not desirable.
From what I have studied from this community, there are, by and large, two solutions
1. Custom Lock Table
2. Checking if the status of the object is the same during the second RFC call, and going ahead only if it was unchanged.
However, I am looking for more credible solution to this problem and would like to know how someone who experienced this issue have handled it.
Thanks in advance,
NeeleshHi Jacob
S_RFC and S_SERVICE This two authorization is nedded while calling RFC module from R3.
first of all test the module in R3. create a role using PFCG assign the tcode. su53 (authorization check) and also assign the S_RFC and S_SERVICE to role.
now test the RFC function module with this role in R3.
if u give any warning/error due to authorization. imediate run tcode su53 in same session or new session
i.e /nsu53 or /osu53.
look which authorization is missing for a object.
assign the relevant object and authorization to role.
any query revert back.
regards,
kaushal -
Hi,
Is it possible to create lock objects at runtime? if not, how do I lock tables at runtime when the table name is specified in the selection screen by the user?
Thanks.
TykenHi tyken,
Try this.
Lock Objects are Created using Tcode SE11.
The Lock object name must be start with EZur name.
Mainly lock objects are used for locking the transactions, tables --etec.
Multiple users can not updated the same transaction at the same time.
Whenever u create a lock object using se11. SAP internally
creates a two function modules:
Enqueue_lockobjname ---For Locking purpose,
dequeue_lockobjname---For Unlocking purpose.
U make use of these fms to lock and unlock transctions, tables..etc.
Steps to create lock objects :
GO TO SE11
Select the radio button "Lock object"..
Give the name starts with EZ or EY..
Example: EYTEST
Press Create button..
Give the short description..
Example: Lock object for table ZTABLE..
In the tables tab..Give the table name..
Example: ZTABLE
Save and generate..
Your lock object is now created..You can see the LOCK MODULES..
In the menu ..GOTO -> LOCK MODULES..There you can see the ENQUEUE and DEQUEUE function
The example is as follws:
EPORT ZLOCK_UNLOCK
MESSAGE-ID ZBDC.
TABLES ZSTUD.
DATA text(8) TYPE c.
CALL SCREEN 100.
*& Module USER_COMMAND_0100 INPUT
text
MODULE USER_COMMAND_0100 INPUT.
CASE SY-UCOMM.
WHEN 'SELECT'.
SELECT SINGLE * FROM ZSTUD WHERE ROLLNO = ZSTUD-ROLLNO.
MESSAGE i004 WITH 'SY-SUBRC:' sy-subrc.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'ENQUEUE'.
CALL FUNCTION 'ENQUEUE_EZLOCK1'
EXPORTING
MODE_ZSTUD = 'X'
ROLLNO = ZSTUD-ROLLNO
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3.
CASE sy-subrc.
WHEN 0.
MESSAGE i004 WITH 'Enqueue successful'(001).
WHEN 1.
text = sy-msgv1.
MESSAGE e004 WITH 'Record already'(002) 'locked by'(003)
text.
CALL TRANSACTION 'SM12'.
WHEN 2 OR 3.
MESSAGE e004 WITH 'Error in enqueue!'(004)
'SY-SUBRC:' sy-subrc.
ENDCASE.
WHEN 'DEQUEUE'.
CALL FUNCTION 'DEQUEUE_EZLOCK1'
EXPORTING
MODE_ZSTUD = 'X'
ROLLNO = ZSTUD-ROLLNO
EXCEPTIONS
OTHERS = 1.
CASE sy-subrc.
WHEN 0.
MESSAGE i004 WITH 'Dequeue successful'(005).
WHEN 1.
MESSAGE e004 WITH 'Error in dequeue!'(006).
ENDCASE.
WHEN 'SM12'.
CALL TRANSACTION 'SM12'.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Module STATUS_0100 OUTPUT
text
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'BASIC'.
ENDMODULE. " STATUS_0100 OUTPUT
Regards,
Chitra -
Hi Experts,
What are lock objects in Abap and what are they used for?
Could you give me info.
Regards
AdetteHi,
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
_SCOPE = 1: The lock is not sent to the update program. The lock is removed when the transaction is ended.
_SCOPE = 2: The lock is sent to the update program. The update program is responsible for removing the lock. The dialog program which requested the lock no longer has an influence on the lock behavior. This is the standard setting for the ENQUEUE function module.
_SCOPE = 3: The lock is also sent to the update program. The lock must be removed in both the dialog program and by the update program. This is the standard setting for the ENQUEUE function module.
Regards
Anver -
Where we use lock objects in our coding like report
what is the purpose of lock objects s? how we use them in real time? like in devoloping reports?
Hi,,.
Lock objects are use in SAP to avoid the inconsistancy at the time of data is being insert/change into database.
SAP Provide three type of Lock objects.
- Read Lock(Shared Locked)
protects read access to an object. The read lock allows other transactions read access but not write access to
the locked area of the table
- Write Lock(exclusive lock)
protects write access to an object. The write lock allows other transactions neither read nor write access to
the locked area of the table.
- Enhanced write lock (exclusive lock without cumulating)
works like a write lock except that the enhanced write lock also protects from further accesses from the
same transaction.
You can create a lock on a object of SAP thorugh transaction SE11 and enter any meaningful name start with EZ Example EZTEST_LOCK.
Use: you can see in almost all transaction when you are open an object in Change mode SAP could not allow to any other user to open the same object in change mode.
Example: in HR when we are enter a personal number in master data maintainance screen SAP can't allow to any other user to use same personal number for changes.
Technicaly:
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.
Check these links
Re: Lock Objects
http://help.sap.com/saphelp_47x200/helpdata/en/ce/931bb5c79911d5993e00508b6b8b11/frameset.htm
http://help.sap.com/saphelp_47x200/helpdata/en/e1/8e51341a06084de10000009b38f83b/frameset.htm
http://www.sapdevelopment.co.uk/dictionary/lock_enqueue.htm
http://help.sap.com/saphelp_nw04/helpdata/en/a2/3547360f2ea61fe10000009b38f839/frameset.htm
http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
http://www.sap-img.com/abap/type-and-uses-of-lock-objects-in-sap.htm
http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
Lock objects are use in SAP to avoid the inconsistancy at the time of data is being insert/change into database.
SAP Provide three type of Lock objects.
- Read Lock(Shared Locked)
protects read access to an object. The read lock allows other transactions read access but not write access to
the locked area of the table
- Write Lock(exclusive lock)
protects write access to an object. The write lock allows other transactions neither read nor write access to
the locked area of the table.
- Enhanced write lock (exclusive lock without cumulating)
works like a write lock except that the enhanced write lock also protects from further accesses from the
same transaction.
You can create a lock on a object of SAP thorugh transaction SE11 and enter any meaningful name start with EZ Example EZTEST_LOCK.
Use: you can see in almost all transaction when you are open an object in Change mode SAP could not allow to any other user to open the same object in change mode.
Example: in HR when we are enter a personal number in master data maintainance screen SAP can't allow to any other user to use same personal number for changes.
Technicaly:
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.
Lock objects are use in SAP to avoid the inconsistancy at the time of data is being insert/change into database.
SAP Provide three type of Lock objects.
- Read Lock(Shared Locked)
protects read access to an object. The read lock allows other transactions read access but not write access to
the locked area of the table
- Write Lock(exclusive lock)
protects write access to an object. The write lock allows other transactions neither read nor write access to
the locked area of the table.
- Enhanced write lock (exclusive lock without cumulating)
works like a write lock except that the enhanced write lock also protects from further accesses from the
same transaction.
You can create a lock on a object of SAP thorugh transaction SE11 and enter any meaningful name start with EZ Example EZTEST_LOCK.
Use: you can see in almost all transaction when you are open an object in Change mode SAP could not allow to any other user to open the same object in change mode.
Example: in HR when we are enter a personal number in master data maintainance screen SAP can't allow to any other user to use same personal number for changes.
Technicaly:
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.
http://help.sap.com/saphelp_nw04/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
GO TO SE11
Select the radio button "Lock object"..
Give the name starts with EZ or EY..
Example: EYTEST
Press Create button..
Give the short description..
Example: Lock object for table ZTABLE..
In the tables tab..Give the table name..
Example: ZTABLE
Save and generate..
Your lock object is now created..You can see the LOCK MODULES..
In the menu ..GOTO -> LOCK MODULES..There you can see the ENQUEUE and DEQUEUE function
Lock objects:
http://www.sap-img.com/abap/type-and-uses-of-lock-objects-in-sap.htm
http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
Match Code Objects:
http://help.sap.com/saphelp_nw2004s/helpdata/en/41/f6b237fec48c67e10000009b38f8cf/content.htm
http://searchsap.techtarget.com/tip/0,289483,sid21_gci553386,00.html
See this link:
http://www.sap-img.com/abap/type-and-uses-of-lock-objects-in-sap.htm
Lock objects are used to synchronize access to the same data by more than one program.
General information about the lock mechanism.
You can synchronize access by several programs to the same data with a logical lock mechanism. This lock mechanism fulfills two main functions:
A program can tell other programs which data records it is just reading or changing.
A program can prevent itself from reading data that is just being changed by another program.
When accessing data records, the records just being edited by other programs can be identified by the entry in the lock table. Such an entry for the lock must define a number of fully specified key fields, that is either a value is passed for the key field or this field is locked generically.
To set locks, a lock object must be defined in the ABAP Dictionary. When this lock object is activated, two function modules (see Function Modules for Lock Requests) are generated with the names ENQUEUE_<lockobjectname> and DEQUEUE_<lockobjectname>.
If data records are to be locked, you must call function module ENQUEUE_<lockobjectname>. The values of the key fields that specify the records to be locked are passed for all the tables contained in the lock object when the function module is called. There is a generic lock if a value is not passed for all the key fields. The function module writes the appropriate lock entry (see Example for Lock Objects). If another program also requests a lock, it will be accepted or rejected depending on the lock mode (see Lock Collisions). The program can then react to this situation.
Locked data records can be unlocked by calling function module DEQUEUE_<lockobjectname>. The key values and the lock mode used to set the lock must be passed to the function module.
Creating Lock Objects
Procedure
Select object type Lock object in the initial screen of the ABAP Dictionary, enter an object name and choose Create. The name of a lock object should begin with an E (Enqueue).
The maintenance screen for lock objects is displayed.
Enter an explanatory short text in the field Short text.
You can then use the short text to find the lock object at a later time, for example with the R/3 Repository Information System.
Enter the name of the primary table of the lock object.
All other tables in the lock object must be linked with the primary table using foreign keys. There are also some restrictions on the valid foreign key relationships.
Select the lock mode of the primary table in the field below it.
The lock mode is used as the default value for the corresponding parameters of the function modules generated from the lock object.
Choose Add if you want to lock records in more than one table with the lock object.
A list of all the tables linked with the primary table using valid foreign keys is displayed. Select the appropriate table. The lock mode of the primary table is copied as lock mode. You can change this setting as required, for example you can assign the lock mode separately for each table.
Similarly, you can add a table linked with the secondary table just added with foreign keys. To do this, place the cursor on the name of the secondary table and choose Add.
If no lock mode is assigned to a table, no lock is set for the entries in this table when the generated function modules are called. You should not assign a lock mode if a secondary table was only used to define a path between the primary table and another secondary table with foreign keys.
Save your entries.
A dialog box appears in which you have to assign the lock object a development class.
You can (optionally) exclude lock parameters (see lock objects) from the function module generation on the Lock parameter tab page. This makes sense for example if you always want to lock a parameter generically.
To do this, simply deselect the Weight flag for the parameter. The parameter is not taken into consideration in the generated function modules. This parameter is then always locked generically.
The name of a lock parameter is usually the name of the corresponding table field. If two fields with the same name are used as lock parameters in the lock object from different tables, you must choose a new name for one of the fields in field Lock parameter.
You can define whether the function modules generated from the lock object should be RFC-enabled on the Attributes tab page.
If you set the Allow RFC flag, the generated function modules can be called from within another system with Remote Function Call.
If you permit Remote Function Calls for an existing lock object, you must ensure that the generated function modules are called from within an ABAP program with parameters appropriate for the type. You should therefore check all programs that use the associated function modules before activating the lock object with the new option.
Choose .
Result
When you activate the lock object, the two function modules ENQUEUE_<lockobjectname> and DEQUEUE_<lockobjectname> are generated from its definition to set and release locks.
Regards
Vasu -
Locking when using a component as an object in the application scope...
I have a component that I am building right now that hold
application settings that are stored in a database table. The
settings are maintained in a structure "variables.settings" within
the component and can only be accessed by get and set methods. I
use the following to create the instance of the object:
<cfset application.settings =
createObject("settings","component").init() />
Now when getting a setting I do not think locking is needed
as its just reading the value and I am not really concerned with a
race condition...
But when using the set method which will update the value of
the setting.... should I be locking that as technically the object
is in a shared variable scope? Or is it safe because its within the
cfc/object?
If locking is needed, would I need to lock when using the set
method? or can I just build the lock into the set method so that
its always there?To disagree with craigkaminsky, I think you only need to lock
if you are
concerned about race conditions and what could happen during
a 'dirty
read' and|or conflicting writes.
A lot of developers have an old impression of ColdFusion that
one *must*
lock all shared scope variable access to maintain a stable
application.
This dates from the ColdFusion 4.5 days where there where
bugs in
ColdFusion that could cause memory leaks and eventual
application
instability if one did not lock shared scope reads and
writes. This has
long been fixed, but the advice persists.
So now it is only a matter of your data and what would happen
if one
user read an old value while it was in the process of being
updated by
another user. Or could two users be updating the same value
at the same
time and cause conflict. If either of those two statements
are true,
then yes you should use locking as required by your
application.
But if they are both false and it does not matter that user A
might get
the old value microseconds before user B changes it. Or there
is no
concern with user A changing it once and user B changing it
again to
something different moments later without knowing the user A
has already
changed it. Then locking is probably unnecessary.
There can be a cost to over locking shared variable writes
and|or reads.
Every time one creates a lock, one is single threading some
portion of
ones code. Depending on how the locking is done, this single
threading
may only apply to individual users or it may apply to every
single user
on the entire server. Either way, too much of this in the
wrong places
can create a significant bottle necks in ones application if
too many
user requests start piling up waiting for their turn through
the locked
block of code. -
Where do I use These lock object FM's (Enqueue & D? and How do I use them?
I created lock object for user defined table (zconsist). The system automatically created 2 FM's (Enquiue & Dequeue).
I created a new TCode and accessing this with mulitple users to do some updates and inserts in that above table.
I used INSERT ZCONSIST statement in 5 places in my program (4 include programs).
Where do I use These FM's? and How do I use them?
I mean before inserting which FM I need to use? after immediately what fm used?.
every insert statemnt before i need to use the respective fm? so 5 places i need to call the respective FM is it right?
thank in advance.Hi Sekhar,
Lock objects are use in SAP to avoid the inconsistancy at the time of data is being insert/change into database.
SAP Provide three type of Lock objects.
Read Lock(Shared Locked)
protects read access to an object. The read lock allows other transactions read access but not write access to
the locked area of the table
Write Lock(exclusive lock)
protects write access to an object. The write lock allows other transactions neither read nor write access to
the locked area of the table.
Enhanced write lock (exclusive lock without cumulating)
works like a write lock except that the enhanced write lock also protects from further accesses from the
same transaction.
You can create a lock on a object of SAP thorugh transaction SE11 and enter any meaningful name start with EZ Example EZTEST_LOCK.
Use: you can see in almost all transaction when you are open an object in Change mode SAP could not allow to any other user to open the same object in change mode.
Example: in HR when we are enter a personal number in master data maintainance screen SAP can't allow to any other user to use same personal number for changes.
Technicaly:
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.
You have to use these function module in your program.
check this link for example.
http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
tables:vbak.
call function 'ENQUEUE_EZLOCK3'
exporting
mode_vbak = 'E'
mandt = sy-mandt
vbeln = vbak-vbeln
X_VBELN = ' '
_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.
Normally ABAPers will create the Lock objects, because we know when to lock and how to lock and where to lock the Object then after completing our updations we unlock the Objects in the Tables
http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
purpose: If multiple user try to access a database object, inconsistency may occer. To avoid that inconsistency and to let multiple user give the accessibility of the database objects the locking mechanism is used.
Steps: first we create a loc object in se11 . Suppose for a table mara. It will create two functional module.:
1. enque_lockobject
1. deque_lockobject
before updating any table first we lock the table by calling enque_lockobject fm and then after updating we release the lock by deque_lockobject.
http://help.sap.com/saphelp_nw04/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
GO TO SE11
Select the radio button "Lock object"..
Give the name starts with EZ or EY..
Example: EYTEST
Press Create button..
Give the short description..
Example: Lock object for table ZTABLE..
In the tables tab..Give the table name..
Example: ZTABLE
Save and generate..
Your lock object is now created..You can see the LOCK MODULES..
In the menu ..GOTO -> LOCK MODULES..There you can see the ENQUEUE and DEQUEUE function
Lock objects:
http://www.sap-img.com/abap/type-and-uses-of-lock-objects-in-sap.htm
http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
Match Code Objects:
http://help.sap.com/saphelp_nw2004s/helpdata/en/41/f6b237fec48c67e10000009b38f8cf/content.htm
http://searchsap.techtarget.com/tip/0,289483,sid21_gci553386,00.html
See this link:
http://www.sap-img.com/abap/type-and-uses-of-lock-objects-in-sap.htm
Check these links -
lock objects
Lock Objects
Lock Objects
kindly reward if found helpful.
cheers,
Hema. -
Regd using of lock object in an abap program
Hi all,
i have created an lock object but doesnot know how to use that lock object in an abap program. can anyone guide me how to use lock object in an abap program.check this sample for Production Order.
<b>* Lock request for order
call function 'ENQUEUE_ESORDER'
exporting
aufnr = p_aufnr
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.</b>
Regards
Prabhu -
Can i use the SAP standard package for lock object creation ?
Dear Guru ,
I want to create a new lock ojbect for my abap program .
When i completed the creation , SAP required a new request and it said the object only can be imported to SAP standard package .
But i saw the help from SAP said :
>* Package begins with A-S or U-X:
>These packages are for SAP standard objects. Customer objects cannot be created in them. Changes to objects of these packages are recorded by the Transport Organizer (Request management) and can be transported (see field transport layer.
In this case , Can i use one of the SAP standard package for this creation ? Does it will affect the SAP system ( such as the system upgrade ) ?
Thanks .
Best Regards,
Carlos Zhang
Moderator message - Please do not use code tags to format text - it should only be used for code
Edited by: Rob Burbank on May 25, 2010 11:12 AMHi Carlos...
First , You will never be able to use any standard SAP Package for your custom programs. So don't go for it.
So in your case what you need to do is , when you save your Lock object ,
- if you want Transport request to be created , then
in the screen shown you need to enter the Z package name (the same package as that of your ABAP Program)
or
-if you want it to be stored as local object , then
specify package as $tmp
Regards,
Uma -
How to use lock object? what we lock either total ztable or only record?
Hi
How to use lock object? what we lock either total ztable or only particular record?
Don't tell create lock object on se11 with E letter & acll it in program with eENQUEUE & DEQUEUE.
just tell me we will lock only particular record or total ztable?
specify with example.
Thanks.Hi
Go to SE11, in the option 'Lock object' enter the name of your lock,
begin with 'E', suppose 'EXXXX' And create. In tab 'Tables' fill the
table name where the record you want to lock exist and select the
lock mode. Lock mode can be shared and exclusive. If 'shared',
when you lock the record, other can also read data, but can not
modify. If 'exclusive', when you lock the record, other can neither
read nor modify the record. After save and activate, you will get two
function module.'ENQUEUE_EXXXX' to lock record,
'DEQUEUE_EXXXX' to release lock on one record.
When use this function module it only lock one record at a time. It
does not lock the table. -
Web Dynpro Callable Object : use of RFCs
Hi All,
I've to create a callable object using Web dynpro.
In this web dynpro to display a table data populated by calling RFC and we need to select one row of the table and sent it as output parameter.
My question is how we gonna set the getDescription Method in this case for creating the Callable Object?
How we define the execute Method in the Interface Controller.
Where I should bind the Model to Controller (Component Controller / Interface Controller)
Can someone explain how we gonna use RFC in Web dynpro while calling it as Callable Object.
Thanks
SrikantHi,
You need to have the SCs for local development of Web Dynpro callable object.
Refer the following documents for more details:
<a href="/people/andre.truong/blog/2006/06/26/working-with-the-apis-of-caf-guided-procedures-nwdi-or-local-development with the APIs of CAF Guided Procedures: NWDI or Local Development?</a>
<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f7be53bb-0b01-0010-1c96-be3cb6799c1b">How to Get NW04s SP7 Guided Procedure APIs for Local Development</a>
<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e3f07a7a-0601-0010-ebbd-b9cfb445b814">Implementing a Web Dynpro Callable Object</a>
Let me know if this solves your issue.
Thanks,
Dipankar -
FM to find user who locked the object using enqueue...
Hello,
How can I find name of user who enqueued the lock object in ABAP ?
Regards,
Jainam.Hi Jainam,
See the SAP documentation, e.g. [FAQ - Lock concepts|http://help.sap.com/saphelp_NW04/helpdata/en/cb/168237d30d974be10000009b38f8cf/content.htm]:
How can I find out who is currently holding the ungranted lock? In other words, how can check the program after an ENQUEUE to determine which use is currently holding the lock so that I can let him or her know?
This graphic is explained in the accompanying text Answer
When the ENQUEUE_... function module is returned, the name of the lock owner is listed in SY-MSGV1.
If you don't want to attempt to lock an object and just check who might own a lock use function module ENQUEUE_READ. Lots of comments in the forum...
Cheers, harald -
HI ,
I have tables which are updated from FM .
the table have user context .
my question is if i need to use lock object if i dont create maintenance view for the tables ?
Or in other words when to use it and when not ?
Regards
JOy
Edited by: Joy Stpr on Oct 18, 2009 8:29 AMHi Joy,
Well to be specific I had used Locking the object in HR module, so i would like to explain based on that.
HR modules have many views in a transaction...and they display data from tables.
now when we change data...at times it is necessary that the data must not be changed at all.
in such scenarios, we lock the object, means no changes can be done.
as 1 friend has rightly mentioned abt enqueue function.
actually theres a function module for enqueue...when u need to make any changes to the data...
u shud 1st enqueue that particular record, so that no one else can edit it, or work on it....after making necessary changes, u then dequeue it...so that it becomes accessible for editing.
so, basically locks, as name suggest can be used to prevent editing.
either temporarily till u r making changes to it....or for a long time...
but the locks can also be removed by coding...
Hope this information helps u
Regards,
Radhika -
What is the use for lock object and how to use the lock objects
Hi Guru's,
I am new to ABAP .Can you please clarify the that what is the use of lock object and how to use the loct object .what is use of the Deque & Enque function modules .hi ,
below are some minfo about lock objects :
Lock Objects
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 .
reward if helpful ,
Regards,
Ranjita -
Lock Object: Enqueue and Dequeue
Hi
Im using VB.Net, SAP .Net to do data entry, updates to
SAP R/3.
Now, I need to lock the data during user changes on
particular documents.
What I done is I created a lock object in SE11. Then
it produce 2 functions which are the ENQUEUE and
DEQUEUE.
Since the data reading from Non-SAP, I check for Allow
RFC and my lock mode is Exclusive and Cumulative.
After that, I also created a remote-enabled RFCs to be
call from VB.Net. These RFCs is calling the ENQUEUE
and DEQUEUE.
When I tested in SAP itself, the locking data is
working perfectly. I checked in SM12, it does shows
the locking entry.
But when I try in VB.Net and call the function
modules, it does not shows any entry in SM12. It is
like nothing happen at all.
After that, I do little test. Firstly I lock the data
from SAP then I run VB.Net, and it does shows the
message who is currently locking the data.
Anybody could help me on this?
Thank you.
Regards.See the following extract from documentation. Check if your lock object definition is satisfying all of them.
<i>Reference Fields for RFC-Enabled Lock Objects
The type of an RFC-enabled function module must be completely defined. The parameters of the generated function module therefore have the following reference fields for RFC-enabled lock objects:
Parameters Reference fields
X_<field name> DDENQ_LIKE-XPARFLAG
_WAIT DDENQ_LIKE-WAITFLAG
_SCOPE DDENQ_LIKE-SCOPE
_SYNCHRON DDENQ_LIKE-SYNCHRON
</i>
Here is the link to the documentation
http://help.sap.com/saphelp_46c/helpdata/en/4f/991f82446d11d189700000e8322d00/frameset.htm
Srinivas
Maybe you are looking for
-
The Crash information is: AdapterDeviceID: 95c4 AdapterVendorID: 1002 Add-ons: TFToolbarX@torrent-finder:1.2.6,{1de0de3c-0b5c-4f67-90c6-689623894991}:0.3,{9fb7d178-155a-4318-9173-1a8eaaea7fe4}:2.1.11,{B17C1C5A-04B1-11DB-9804-B622A1EF5492}:1.2.1,{c0c9
-
Transferri​ng Contacts from a BB Q10 to a BB Bold 9780
I have a Q10 with one provider ( Telus) and also have a bold 9780 with another provider ( bell mobility) . I will be stopping to use my Q10 and need to transfer my contacts to my Bold 9780. How can this be done??
-
Why is music is skipping with airport express?
It worked fine for more than a year. Now my music is skipping. I have an airport extreme router and airport express on my stereo to stream itunes from my macbook wireless. It's apples to apples to apples and not working. Help me apple!
-
Please Help , Cant see flash objects
I cannot see certain flash objects. some games and videos i can some not. I was reading another person changed their storage settings And I remember I had to do something with my manager so I went back to the flash manager to check my settings and I
-
How can I setup a macro that types a special character when I press a key on the keyboard?
I have an aplication where I am unable to insert a tilde (~) by pressing alt+Ñ. (I have a spanish keyboard) The only way this app lets my input a tilde, is by copying and pasting it in, which is extremely annoying and time consuming. Is there any wa