How to empty a table and repopulate it using a locking mechanisme by admin
ABAP May 15th, 2008
Sometimes it’s just easier and more performant to delete all rows from a table and repopulate it.
I used this scenario for a weekly sheduled job to refresh a custom table,containing all the email adresses from our employes.
In the first step, i populate an internal table with the type of the database table.
-
LOOP AT INPUT-MT_adusers_CRM-RECORD-ROW into ls_adusers_data.
-
IF ls_adusers_data-email CA '@'.
-
MOVE sy-mandt TO wa_admails_data-mandt.
-
MOVE ls_adusers_data-userid TO wa_admails_data-userid.
-
MOVE ls_adusers_data-fullname TO wa_admails_data-fullname.
-
MOVE ls_adusers_data-email TO wa_admails_data-email.
-
APPEND wa_admails_data TO it_admails_data.
-
ENDIF.
-
ENDLOOP.
-
*enqueue table
-
CALL FUNCTION 'ENQUEUE_E_TABLEE'
-
EXPORTING
-
mode_rstable = 'E'
-
tabname = '/G/ADMAILS'
-
EXCEPTIONS
-
foreign_lock = 1
-
system_failure = 2
-
OTHERS = 3.
-
*delete all mails
-
DELETE FROM /G/ADMAILS.
-
*insert
-
insert /G/ADMAILS from table it_admails_data.
-
*dequeue table
-
CALL FUNCTION 'DEQUEUE_E_TABLEE'
-
EXPORTING
-
mode_rstable = 'E'
-
tabname = '/G/ADMAILS'.
About