Row level locking of database table

...Previous

6.       Just one more change in table maintenance screen.  Now open table maintenance function  group(ZTEST_SHUKS3)  in SE80.We know for table maintenance SAP automatically creates code in the function group. Now we will make some modification in that existing code to change the behavior. Open the screen you created through table maintenance and add one module. 

           

Open the screen 0001 and add one module in PBO of the screen as shown in figure below. 

Check the code below to be added in the module m_change_locking. 

MODULE m_change_locking OUTPUT.
*Call the function module corresponding to the lock object we created
  
CALL FUNCTION 'ENQUEUE_EZTEST_SHUKS3'
    
EXPORTING
      matnr          = ztest_shuks3-matnr
      werks          = ztest_shuks3-werks
    
EXCEPTIONS
      foreign_lock   = 
1
      system_failure = 
2
      
OTHERS         = 3.
  
IF sy-subrc NE 0.
* row is locked..hence gray..
    
LOOP AT SCREEN.
      
screen-input = 0.
      
MODIFY SCREEN.
    
ENDLOOP.
  
ENDIF.
ENDMODULE.                 " m_change_locking  OUTPUT 

7.       Now we are ready for testing. Call the transaction once and make some entries in table. In below screenshot I have entered some random values. Since we have not maintained any check tables etc, so values may be invalid. That can be taken care in real scenario. 

 

Save data. 

Let’s call two sessions of the transaction ZTEST_SHUKS3.

Session 1   

In first session we will call the transaction ZTEST_SHUKS3 and try to open some existing values for table maintenance. 

    

Let’s open an existing value material = MAT1 and Plant = 0678. 

        

So the entry opens in change mode. 

Now open a second session of the transaction and see. Now the same material and plant combination can not be changed by any other user or session. 

Session 2  

Open transaction ZTEST_SHUKS3 

 

So we can see that our transaction is able to achieve a row level locking and has removed table level locking.

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image