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 a ztable using function module or memory id

Former Member
0 Likes
469

hello experts,

i am facing a problem in ALV grid output (editable) - when user editing and saving data into the ztable - other user should not able to save the data and error msg to be displayed.

i am using the function modules for locking the whole table - enqueue_eztable and dequeue_eztable. i can see the table as locked in sm12, but i can also do the updating and save data.

is there anyother function module to work with?

another way i am doing is -

DATA: text4 TYPE c,
        text5 TYPE c.
  IMPORT text4 TO text5 FROM MEMORY ID 'Y222'.
  IF sy-subrc = 0.
    IF text5 = 'X'.
      MESSAGE e000(z1) WITH 'SOME USER IS ACCESSING THE PROGRAM'.
    ENDIF.
  ELSE.
    EXPORT text4 = 'X' TO MEMORY ID 'Y222'.
    PERFORM update_dbase.
    FREE MEMORY ID 'Y222'.
  ENDIF.

this method also not working.

plz help me, how to avoid other user accessing the data when another user is working on it?

thanks.

2 REPLIES 2
Read only

Former Member
0 Likes
416

Hi,

Create lock object for the table and use below method

  • Lock Table ZWMDASHBOARD

CALL FUNCTION 'ENQUEUE_EZWMDASHBOARD'

EXPORTING

mode_zwmdashboard = 'E'

mandt = sy-mandt

EXCEPTIONS

foreign_lock = 1

system_failure = 2

OTHERS = 3.

IF sy-subrc <> 0.

RAISE unable_to_lock. " Exception

ELSE.

  • Modify Table ZWMDASHBOARD.

MODIFY zwmdashboard FROM TABLE t_zwmdashboard[].

IF sy-subrc <> 0.

  • Do Nothing

ENDIF.

  • Unlock table ZWMDASHBOARD.

CALL FUNCTION 'DEQUEUE_EZWMDASHBOARD'

EXPORTING

mode_zwmdashboard = 'E'

mandt = sy-mandt.

ENDIF.

Hope this helps..

Read only

Former Member
0 Likes
416

HI,

It is always better to use ENQUEUE/DEQUEUE for locking/unlocking functionality

If you want to use the memory ID, you can use the below format

IMPORT text4 TO text5 FROM MEMORY ID 'Y222'. (Here you will get values to text5 )

EXPORT text4 FROM text5 TO MEMORY ID 'Y222'. (Value of text5 will be stored to Memory ID)

Regards,

Seema