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: 

regarding lock database table

Former Member
0 Kudos

Hello expert.

below is my requirement.

while count <> 0.

do some processing to fill wa_tab.

append wa_tab to i_tab.

endwhile.

modify db_tab from table i_tab.

Now i want to lock records at the time of update database record.

please let me which one of below code is right and gud in performance.

1.

while count <> 0.

do some processing to fill wa_tab.

append wa_tab to i_tab.

lock entry in wa_tab. using lock object.

endwhile.

modify db_tab from table i_tab.

loop at i_tab into wa_tab.

unlock entry of database entry using wa_tab

endloop.

2.

while count <> 0.

do some processing to fill wa_tab.

append wa_tab to i_tab.

endwhile.

lock the comple table

modify db_tab from table i_tab.

unlock complete table.

please add something if it is required and not there in the above pseudo code

thanks in advance for ur valuable help.

4 REPLIES 4

Former Member
0 Kudos

Hi,

In the First step also, lock the complete table

Regards

Sudheer

Former Member
0 Kudos

Hi,

In this case you can use the F.Ms ENQUEUE and DEQUEUE

while count <> 0.

do some processing to fill wa_tab.

append wa_tab to i_tab.

endwhile.

<b>CALL FUNCTION 'ENQUEUE_EXXXX'</b>

modify db_tab from table i_tab.

if sy-subrc = 0.

write : 'Records are succ updated'.

endif.

<b>CALL FUNCTION 'DEQUEUE_EZVIJ'</b>

Suppose if ur updating Z-table check whether lock objects has created or not, if not you can create the lock object by using SE11.

<b>Reward with points if useful.</b>

Regards,

Vijay

former_member194613
Active Contributor
0 Kudos

Do not locfk the complete table! Always lock only as little as necessary. Sooner or later you want to run your programm in parallel (multi-user), then the locking of the complete table will stop the second user.

Use insert or update if possible, and modify only if you do not know whether records exist already!

Siegfried

raymond_giuseppi
Active Contributor
0 Kudos

Theoretically do something like

*   Fill table when locking records
    LOOP.
      " some processing
      PERFORM lock record. " ENQUEUE
      " some processing again
      APPEND record TO update_table.
    ENDLOOP.
*   Call in update task a Function Module (just UPDATE from table in it)
    CALL FUNCTION 'Zupdate' IN UPDATE TASK
      table
        update_table = update_table.
*   Validate
    COMMIT WORK. " don't wait, 
*   the task will update data and release locks

Regards<i></i>