http://www.architectsap.com/blog/sap/sap-abap-webservices-creation-options/ http://www.sapdev.co.

uk/dictionary/lock_enqueue.htm
SAP Database locking using ENQUEUE and DEQUEUE

SAP provides you with the ability to restrict access to data while the table is being updated. This is fairly simple to implement via the use of a lock object (Created in SE11). Step 1 - Create Lock object (SE11)

S = Read Lock. * _SCOPE = '2' * _WAIT = ' ' * _COLLECT = ' ' * If exceptions are not used.Step 2 . This function module must be called before any update takes place.ABAP code to lock table entries Add the following code in-order to create the table lock. If a lock has already been taken out it will display the appropriate message. X = Exclusive not cumulative mandt = sy-mandt KEYFIELD1 = "Value KEYFIELD2 = "Value KEYFIELD3 = "Value . message is displayed within FM EXCEPTIONS FOREIGN_LOCK = 1 SYSTEM_FAILURE = 2 OTHERS = 3. CALL FUNCTION 'ENQUEUE_EZ_ZTABLENAME' EXPORTING mode_ZTABLENAME = 'E' "E = Write Lock. Retrieve message displayed within Function Module . * X_KEYFIELD1 = ' ' * X_KEYFIELD2 = ' ' * X_KEYFIELD3 = ' ' ..... * IF sy-subrc <> 0.

Step 3 . ld_gname = 'ZTABLENAME'. CALL FUNCTION 'DEQUEUE_EZ_ZTABLENAME' EXPORTING MODE_ZTABLENAME = 'E' MANDT = SY-MANDT mandt = sy-mandt KEYFIELD1 = "Value KEYFIELD2 = "Value KEYFIELD3 = "Value . exit. . default is SY-UNAME but need to use * to return locks for all users TABLES ENQ = it_enq EXCEPTIONS COMMUNICATION_FAILURE = 1 SYSTEM_FAILURE = 2 OTHERS = 3. "will need to check values returned by FM to check what values are needed to build ld_garg value concatenate sy-mandt KEYFIELD1 KEYFIELD2 KEYFIELD3 into ld_garg . if wa_enq-guname eq sy-uname. ***************OPTIONAL . ENDIF. endloop. "This is the name of the lock object as shown in tcode SM12 CALL FUNCTION 'ENQUEUE_READ' EXPORTING GCLIENT = SY-MANDT GNAME = ld_gname "Lock opject name GUNAME = '*' "User name. "Entry already being updated by you else. ld_garg type SEQG3-GARG. ld_gname type SEQG3-GNAME.. loop at it_enq into wa_enq where garg cs ld_garg. check sy-subrc eq 0.. ***************OPTIONAL EXIT. wa_enq like line of it_enq. "Entry already being updated by someone else endif.ABAP code to Remove table lock(s) The following code will remove the lock for the specific table entries.Get more details of existing lock * Also within here you can also use ENQUEUE_READ to find out more details about the existing lock data: it_enq type STANDARD TABLE OF SEQG3.message id sy-msgid type 'I' number sy-msgno with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

.. _SCOPE _SYNCHRON _COLLECT .* * * * * * X_KEYFIELD1 X_KEYFIELD2 X_KEYFIELD3 . = ' ' = ' ' = ' ' = '3' = ' ' = ' ' .

Sign up to vote on this title
UsefulNot useful