Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Locking the Custom table

Former Member
0 Kudos

I have a custom tble zcustom_tab. I am modifying the entries in the program . Right now i am locking the table.

Now instead of table locking, i want the record level locking.

How ?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Create a lock object for the table in SE11. This will create 2 FMs one for locking and other for unlocking.

While calling the locking FM, pass all the primary fields of the table and this will lock only that record in the table.

if you dont pass the primary field values, the entire table would be locked.

For more information on lock objects, check the below link.

http://help.sap.com/saphelp_nw70/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm

For creating lock objects, check the below link.

http://help.sap.com/saphelp_nw70/helpdata/en/cf/21eef3446011d189700000e8322d00/content.htm

Hope this helps. Rwd points if helpful.

Thanks,

Balaji

3 REPLIES 3

Former Member
0 Kudos

Hi,

try if this code helps.

&----


*& Report ZLOCKING *

*& *

&----


*& *

*& *

&----


REPORT zlocking .

DATA : tab_emp TYPE TABLE OF zemp_51772,

wa_emp TYPE zemp_51772.

wa_emp-emp_no = '102'.

wa_emp-emp_id = '157'.

wa_emp-emp_name = 'SIVA'.

wa_emp-emp_dept = 'SAP'.

APPEND wa_emp TO tab_emp.

CLEAR wa_emp.

wa_emp-emp_no = '128'.

wa_emp-emp_id = '138'.

wa_emp-emp_name = 'RAMA'.

wa_emp-emp_dept = 'SAP'.

APPEND wa_emp TO tab_emp.

CLEAR wa_emp.

wa_emp-emp_no = '133'.

wa_emp-emp_id = '121'.

wa_emp-emp_name = 'KRISHNA'.

wa_emp-emp_dept = 'SAP'.

APPEND wa_emp TO tab_emp.

CLEAR wa_emp.

CALL FUNCTION 'ENQUEUE_E_TABLEE'

EXPORTING

mode_rstable = 'X'

tabname = 'ZEMP_51772'

  • varkey =

  • X_TABNAME = ' '

  • X_VARKEY = ' '

  • _SCOPE = '2'

  • _WAIT = ' '

  • _COLLECT = ' '

EXCEPTIONS

foreign_lock = 1

system_failure = 2

OTHERS = 3

.

IF sy-subrc EQ 0.

INSERT zemp_51772 FROM TABLE tab_emp.

ENDIF.

CALL FUNCTION 'DEQUEUE_E_TABLEE'

EXPORTING

mode_rstable = 'X'

tabname = 'ZEMP_51772'

  • VARKEY =

  • X_TABNAME = ' '

  • X_VARKEY = ' '

  • _SCOPE = '3'

  • _SYNCHRON = ' '

  • _COLLECT = ' '

.

IF sy-subrc EQ 0.

WRITE:/ 'Unlocked the Table'.

ENDIF.

Thanks&regards,

Sravani.

Former Member
0 Kudos

Hi,

Create a lock object for the table in SE11. This will create 2 FMs one for locking and other for unlocking.

While calling the locking FM, pass all the primary fields of the table and this will lock only that record in the table.

if you dont pass the primary field values, the entire table would be locked.

For more information on lock objects, check the below link.

http://help.sap.com/saphelp_nw70/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm

For creating lock objects, check the below link.

http://help.sap.com/saphelp_nw70/helpdata/en/cf/21eef3446011d189700000e8322d00/content.htm

Hope this helps. Rwd points if helpful.

Thanks,

Balaji

venkat_o
Active Contributor
0 Kudos

Hi, To lock perticular record to modify in the program 1. Create Lock object by specifying all key fields. 2. When u activate 2 FMs ENQUE_<lockobject>, DEQUE_<<lockobject> are created automatically. Call ENQUE* FM in your program and pass exact record which needs to be locked and modify the table record and finall call DEQUE* FM. Regards, Venkat.O