Application Development and Automation 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: 
Read only

Lock Objects Problem while updating entries in custom table

Former Member
0 Likes
3,111

Hi Friends,

Iam updating a custom table ztable from internal table entries.

ie : Modify ZTABLE from table ITAB.

Now the entries are updating and inserting perfectly..

But my problem is i need to use lock objects before doing this..

I have created a lock obect EZTABLE with all th ekey fields of the table.. ie : it has 2 key fields

item & matnr .

Now how to use lock objects here.. do i need to loop the internal table and use enque & deque function module each and every time in loop or use it out side the loop..

Can any one explain me this..

Regards,

Kumar

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,612

Hi Kumar ,

  • Lock the tables using the enqueue fm .

  • Modify ZTABLE from table ITAB.

  • Unlock the tables using the dequeue fm.

Try the below code..

**- Lock the table for updation

CALL FUNCTION 'ENQUEUE_E_TABLEE'

EXPORTING

mode_rstable = 'E'

tabname = 'ZTABLE'

EXCEPTIONS

foreign_lock = 1

system_failure = 2

OTHERS = 3.

  • IF sy-subrc <> 0.

  • ENDIF.

**- Updating the values in the afterbilled table.

MODIFY ztableFROM TABLE itab .

COMMIT WORK.

**- Unlock the table after Updation.

CALL FUNCTION 'DEQUEUE_E_TABLEE'

EXPORTING

mode_rstable = 'E'

tabname = 'ZTABLE'.

Hope this helps.

Regards,

Chitra

4 REPLIES 4
Read only

Former Member
0 Likes
1,612

Read only

Former Member
0 Likes
1,613

Hi Kumar ,

  • Lock the tables using the enqueue fm .

  • Modify ZTABLE from table ITAB.

  • Unlock the tables using the dequeue fm.

Try the below code..

**- Lock the table for updation

CALL FUNCTION 'ENQUEUE_E_TABLEE'

EXPORTING

mode_rstable = 'E'

tabname = 'ZTABLE'

EXCEPTIONS

foreign_lock = 1

system_failure = 2

OTHERS = 3.

  • IF sy-subrc <> 0.

  • ENDIF.

**- Updating the values in the afterbilled table.

MODIFY ztableFROM TABLE itab .

COMMIT WORK.

**- Unlock the table after Updation.

CALL FUNCTION 'DEQUEUE_E_TABLEE'

EXPORTING

mode_rstable = 'E'

tabname = 'ZTABLE'.

Hope this helps.

Regards,

Chitra

Read only

Former Member
0 Likes
1,612

you can use instead of creating objetc

CALL FUNCTION 'ENQUEUE_E_TABLEE'

EXPORTING

MODE_RSTABLE = 'E'

TABNAME = 'YOUR TABLE NAME'

VARKEY = L_VARKEY

EXCEPTIONS

FOREIGN_LOCK = 1

SYSTEM_FAILURE = 2

OTHERS = 3.

IF SY-SUBRC IS INITIAL

MODIFY TABLE

then

CALL FUNCTION 'DEQUEUE_E_TABLEE'

EXPORTING

MODE_RSTABLE = 'E'

TABNAME = 'YOur TABKE NAME'

VARKEY = L_VARKEY..

Read only

Former Member
0 Likes
1,612

hi kumar,

**check if the equipment is already locked by user, if yes, trigger a mail

CALL FUNCTION 'ENQUEUE_EIEQUI'

EXPORTING

  • MODE_EQUI = 'E'

  • MANDT = SY-MANDT

equnr = lv_equi_temp

  • X_EQUNR = ' '

  • _SCOPE = '2'

  • _WAIT = ' '

  • _COLLECT = ' '

EXCEPTIONS

foreign_lock = 1

system_failure = 2

OTHERS = 3.

IF sy-subrc <> 0.

lv_subrc1 = sy-subrc.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ELSE.

CALL FUNCTION 'DEQUEUE_EIEQUI'

EXPORTING

  • MODE_EQUI = 'E'

  • MANDT = SY-MANDT

equnr = lv_equi_temp

  • X_EQUNR = ' '

  • _SCOPE = '3'

  • _SYNCHRON = ' '

  • _COLLECT = ' '

.

ENDIF.

try like this to check if the object is locked....

u can also use

call function 'ENQUEUE,.

do the needful changes update the database then commit work

then call function 'DEQUEUE'

hope this helps,

tanmaya