‎2010 Mar 18 12:28 PM
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
‎2010 Mar 18 12:36 PM
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
‎2010 Mar 18 12:32 PM
‎2010 Mar 18 12:36 PM
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
‎2010 Mar 18 12:41 PM
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..
‎2010 Mar 18 1:35 PM
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