‎2005 Sep 19 10:12 AM
Hi all,
I have 7000 records to be inserted/modified to a customized table. Program will be run everyday at night to update the customised table.
What is the best method to update it? Is it using FM or just put commit after the loop?
many thanks.
‎2005 Sep 19 10:26 AM
Alia,
I am not sure what you are asking about. FM is different from commit after the loop.
Its always better that you update your table with all the records and then finally do a commit, whether you are doing in a program or a function module. If the number of records is too large, you can think of an intermediate commit after say n(1000) records.
Where is the confusion?
Regards,
Ravi
‎2005 Sep 19 10:36 AM
Hi Ravi,
I am sorry if my question is unclear. I am asking about how to update the customised table.
I am thinking of putting commit after the loop, where inside the loop, right now I directly move value to the customised table, for example:
loop at itab.
zso-matnr = itab-matnr.
endloop.
commit work.
or
using a functional module to update entire record:
UPDATE ZSTB_SO_LOG FROM i_logtab.
which one is the best? in term of performance impact etc etc.
many thanks
alia
‎2005 Sep 19 10:40 AM
Alia,
Looks like your internal table is of the same structure as of the database table. In this case you can go with the ONE statement approach.
You are using a UPDATE statement. On the other hand if you have mix of new records as well as updated records you can go for MODIFY statement.
Regards,
Ravi
Note : Please reward points if this helps you.
‎2005 Sep 19 10:31 AM
Use array command which will Insert / modiy in one database operation .
MODIFY <DBTAB> from ITAB.
Itab is internal table having same structure as database tables . Beofre doing the above database insert you may like to do all validations on ITAB . In above the Key will be matched . If it exists is db table record will be updated else new record will be inserted.
No specific commit work is required . It will be triggered implicitly the moment the program ends.
Cheers
‎2005 Sep 19 4:40 PM
7000 records isn't really a lot. Since each commit has some overhead, I'd just update the records and commit at the end.
rob