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: 

Lock a standard sap table

Former Member
0 Kudos

Hi all,

I am trying to updtae the entries of the table KNMT . To make sure thta no body else is modifyng the enroes from VD52 I want to lock the table . For this I am using the FM <b>ENQUEUE_E_TABLE</b> . But when I check in SM12 for any locked objects I couldn't see any . Can you tell me what could be the reason . I am posting my code .


REPORT ZLOCK_CHECK .

data : varkey like RSTABLE-VARKEY .

varkey = sy-mandt .

CALL FUNCTION 'ENQUEUE_E_TABLE'
 EXPORTING
   MODE_RSTABLE         = 'E'
   TABNAME              = 'KNMT'
   VARKEY               = varkey
*   X_TABNAME            = ' '
*   X_VARKEY             = ' '
*   _SCOPE               = '2'
*   _WAIT                = ' '
*   _COLLECT             = ' '
* EXCEPTIONS
*   FOREIGN_LOCK         = 1
*   SYSTEM_FAILURE       = 2
*   OTHERS               = 3
          .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.


break-point .
write : sy-subrc .

This stops in debugging mode . But no entry ids found in SM12 but sy-subrc is ZERO .

Can anyone please help me with this .

Regards,

Vijay .

11 REPLIES 11

sunilachyut
Contributor
0 Kudos

Instead of locking at the table level, try the FM ENQUEUE_EVKNMT and see if it meets your requirements. I guess you will be updating one record any given time so this might help you in what you are trying to accomplish.

hith

Sunil Achyut

0 Kudos

Hi Sunil,

I tried this and this is giving other problems so I am trying to use the above said FM .

Regards,

Vijay .

0 Kudos

What problems are you having when you tried locking it at the record level? Its better to go at a record level than at a table level. You can check the system messages (msgid, msgno) to see why it dint lock.

hith

Sunil Achyut

Message was edited by: Sunil Achyut

0 Kudos

Try the following and see,

concatenate sy-mandt VKORG VTWEG KUNNR MATNR into varkey.

The above is assuming you have all the primary keys of the record.

hith

Sunil Achyut

0 Kudos

Hi all,

I did not make any changes to the code . But now I can see the lock entry in SM12 .

Thank you all guys for yuor quick replies .

Regards,

varun .

Former Member
0 Kudos

I run your code and it worked fine

Max

0 Kudos

Hi Max,

Were you able to see an enrty in SM12 ??

Rich ,

I wrote a call transaction program for that but it is not getting executed in background mode so we are tryinmg to updtae the table .

Regards,

Vijay .

0 Kudos

Hi

Yes I saw it in SM12

I'm using 4.6C

Max

0 Kudos

Hi Max,

I am also using 4.6C but not able to see the entry in SM12 . I dont know why .

Regards,

Vijay .

0 Kudos

Hi Vijay,

I ran the progtram and see the lock entry in SM12. I am on 4.7.

here is the entry when i saw in SM12.

cl. user Time Mode Table Lockargument

_____________________________________________________________________

020 Dev_id 13:55:16 E RSTABLE KNMT

Regards,

Vivek

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Do you think it is a good idea to modify a standard SAP table? This is usually not a good idea.

Regards,

Rich Heilman