‎2007 Aug 01 6:14 PM
Hi All,
i need to do direct update to the database table and the table has apprx 60,000 records . i am getting all records from database table to internal table and has to chnage the one of the field value and pass it to the database table . So i am looping the internal table and what is the best approach to update the database table is it to use UPDATE Pa0001 SET KOSTL = it_0001-KOSTL from table it_0001 each time in the loop to update each record and commit work which hits database for each record or use the statement UPDATE pa0001 from table it_0001 and if count = 1000 then COMMIT work in this way it will hit the database for every 1000 records . Appreciate your suggestions,
Thanks,
Latha.
‎2007 Aug 01 6:15 PM
‎2007 Aug 01 6:19 PM
Thanks Rich for quick response . Our team lead has accepted to do the direct table update as we are doing it one time and if we use other approach the changed by date field is changed and we dont want that to happen as it effects some of our interfaces so we are proceeding with direct table update . Please suggest which UPDATE method is appropriate .
Thanks,
Latha.
‎2007 Aug 01 6:22 PM
‎2007 Aug 01 6:30 PM
HI,
see this code
<b>*-- Here only two hits to the database.</b>
tables : ztable.
data : itab like standard table of ztable.
select * from ztable into table itab.
if sy-subrc eq 0.
delete ztable from itab.
loop at itab.
do the changes to itab field.
endloop.
insert into ztable from table itab.
endif.
Thanks,
Mahesh
‎2007 Aug 01 6:39 PM
You can use :
UPDATE PA0000 FROM TABLE T_PA0000.
I tried it and it worked..
Reward for useful answers
Regards
Pradeep
‎2007 Aug 01 7:00 PM
My Code to update PA0006 is :
DATA: t_pa0006 TYPE STANDARD TABLE OF pa0006 INITIAL SIZE 0,
wa_pa0006 LIKE LINE OF t_pa0006,
w_lin TYPE i.
FIELD-SYMBOLS: <fs_pa0006> LIKE LINE OF t_pa0006.
SELECT * FROM pa0006 INTO TABLE t_pa0006 WHERE uname = 'PKHAROR'.
LOOP AT t_pa0006 ASSIGNING <fs_pa0006>.
<fs_pa0006>-stras = 'My Street'.
ENDLOOP.
DESCRIBE TABLE t_pa0006 LINES w_lin.
UPDATE pa0006 FROM TABLE t_pa0006.
IF sy-subrc EQ 0.
COMMIT WORK.
WRITE:/ w_lin, ' Records have been updated..'.
ENDIF.
Reward points for useful answers
Regards
Pradeep
Regards
Pradeep