‎2005 Aug 24 5:32 AM
hi,
what is difference between sap locking and database locking. Iam locked the table mara by using lock objects.
But iam unable to unlock the mara table. I give u the coding. Please check it.
REPORT zlock .
CALL FUNCTION 'ENQUEUE_EZTEST3'
EXPORTING
MODE_MARA = 'S'
MANDT = SY-MANDT
MATNR = 'SOU-1'.
call transaction 'MM02'.
CALL FUNCTION 'DEQUEUE_EZTEST3'
EXPORTING
mode_mara = 'E'
mandt = sy-mandt
matnr = 'SOU-1'.
IF sy-subrc = 0.
WRITE: 'IT IS unlocked'.
ENDIF.
‎2005 Aug 24 5:57 AM
Hi Paluri
Here is the difference between SAP locks and Database locks, i will try to find the solution to your code.
Regards
Ashish
Database Locks: The database system automatically sets database locks when it receives change statements (INSERT, UPDATE, MODIFY, DELETE) from a program. Database locks are physical locks on the database entries affected by these statements. You can only set a lock for an existing database entry, since the lock mechanism uses a lock flag in the entry. These flags are automatically deleted in each database commit. This means that database locks can never be set for longer than a single database LUW; in other words, a single dialog step in an R/3 application program.
Physical locks in the database system are therefore insufficient for the requirements of an R/3 transaction. Locks in the R/3 System must remain set for the duration of a whole SAP LUW, that is, over several dialog steps. They must also be capable of being handled by different work processes and even different application servers. Consequently, each lock must apply on all servers in that R/3 System.
SAP Locks:
To complement the SAP LUW concept, in which bundled database changes are made in a single database LUW, the R/3 System also contains a lock mechanism, fully independent of database locks, that allows you to set a lock that spans several dialog steps. These locks are known as SAP locks.
The SAP lock concept is based on lock objects. Lock objects allow you to set an SAP lock for an entire application object. An application object consists of one or more entries in a database table, or entries from more than one database table that are linked using foreign key relationships.
Before you can set an SAP lock in an ABAP program, you must first create a lock object in the ABAP Dictionary.
‎2005 Aug 24 5:57 AM
Hi Paluri
Here is the difference between SAP locks and Database locks, i will try to find the solution to your code.
Regards
Ashish
Database Locks: The database system automatically sets database locks when it receives change statements (INSERT, UPDATE, MODIFY, DELETE) from a program. Database locks are physical locks on the database entries affected by these statements. You can only set a lock for an existing database entry, since the lock mechanism uses a lock flag in the entry. These flags are automatically deleted in each database commit. This means that database locks can never be set for longer than a single database LUW; in other words, a single dialog step in an R/3 application program.
Physical locks in the database system are therefore insufficient for the requirements of an R/3 transaction. Locks in the R/3 System must remain set for the duration of a whole SAP LUW, that is, over several dialog steps. They must also be capable of being handled by different work processes and even different application servers. Consequently, each lock must apply on all servers in that R/3 System.
SAP Locks:
To complement the SAP LUW concept, in which bundled database changes are made in a single database LUW, the R/3 System also contains a lock mechanism, fully independent of database locks, that allows you to set a lock that spans several dialog steps. These locks are known as SAP locks.
The SAP lock concept is based on lock objects. Lock objects allow you to set an SAP lock for an entire application object. An application object consists of one or more entries in a database table, or entries from more than one database table that are linked using foreign key relationships.
Before you can set an SAP lock in an ABAP program, you must first create a lock object in the ABAP Dictionary.
‎2005 Aug 24 6:06 AM
Hi,
Try with this function module
CALL FUNCTION 'ENQUEUE_EMMARAS'
EXPORTING
MATNR = 'material number'
EXCEPTIONS
FOREIGN_LOCK = 2
SYSTEM_FAILURE = 3.
call transaction 'MM02'.
CALL FUNCTION 'DEQUEUE_EMMARAS'
EXPORTING
MODE_MARA = 'S'
MANDT = SY-MANDT
MATNR = 'material number'
X_MATNR = ' '
_SCOPE = '3'
_SYNCHRON = ' '
_COLLECT = ' '.
IF sy-subrc = 0.
WRITE: 'IT IS unlocked'.
ENDIF.
Cheers,
Sasi
‎2005 Aug 24 6:08 AM
Hi,
Continues to my previous posting,
Database lock is a physical and SAP lock is a logical one.
Cheers,
Sasi
‎2005 Aug 24 6:17 AM
Hi Paluri
To unlock table MARA (or any table): use txn SM12, supply your table name, client and user name and you will get the list of lock entries. Here, you can manage to delete them.
Regards
Ashish
‎2005 Aug 24 6:18 AM
‎2005 Aug 24 6:21 AM
ashish,
i want to unlock the object by using function module.
‎2005 Aug 24 6:25 AM
Hi Paluri
Atleast release the lock using SM12 first so that you can try locking and unlocking again with whatever modified code you have. I will also try to see for the function module options
Cheers
Ashish
‎2005 Aug 24 6:30 AM
To unlock objects use fm DEQUEUE_ALL
for material master DEQUEUE_MATERIAL_MASTER.
regds
gv
‎2005 Aug 24 6:29 AM
Hi Paluri,
try that:
data sptab type rstable.
sptab-TABNAME = 'MARA'.
concatenate sy-mandt 'SOU-1' into sptab-VARKEY.
*lock
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
TABNAME = sptab-TABNAME
VARKEY = sptab-VARKEY
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3.
...
*unlock
CALL FUNCTION 'DEQUEUE_E_TABLE'
EXPORTING
TABNAME = RSTABLE-TABNAME
VARKEY = RSTABLE-VARKEY.
Andreas
‎2005 Aug 24 6:39 AM
Hi Paluri
As already pointed out by someone, use can use DEQUEUE_ALL or DEQUEUE_MATERIAL_MASTER
But beware of using dequeue_all, you can very well imagine what may happen........
You can search for more function modules using keyword dequeue in SE37.
Regards
Ashish
‎2005 Aug 24 6:41 AM
ashish,
what is the ARGUMENT IN SM12. IT IS NOT ACCEPTING MATERIAL NUMBER
‎2005 Aug 24 6:51 AM
Hi Paluri
Don't supply lock argument, just supply table name, client and username (id) and press list, you will get the whole list.
Regards
Ashish
‎2005 Aug 24 7:27 AM
Hi,
chek out this link for Database locking:
http://www.sapdevelopment.co.uk/dictionary/lock_enqueue.htm
Regards,
Anjali
‎2005 Aug 24 7:31 AM
Hi Paluri
Please look at the link below for Lock Objects help:
http://help.sap.com/saphelp_nw04/helpdata/en/af/22ab01dd0b11d1952000a0c929b3c3/frameset.htm
In this link, the topic 'Function modules for lock objects' may be of your interest, especially the parameter '_synchron'.
The DEQUEUE function module also has the parameter _SYNCHRON. If X is passed, the DEQUEUE function waits until the entry has been removed from the lock table. Otherwise it is deleted asynchronously, that is, if the lock table of the system is read directly after the lock is removed, the entry in the lock table may still exist.
Cheers
Ashish
‎2005 Aug 24 2:37 PM
You really shouldn't be doing it this way. Transaction MM02 will lock anything it needs to just before it saves it and release it immediately after. If you lock it using your code, the material will be locked for as long as you are in the transaction. If you are called away, this could be a long time. In the meantime, no one else will be able to change it.
It's always best to leat SAP handle locking its own objects.
Rob