2015 Jan 14 3:43 PM
Hi all,
I have two ways to updata a DB table.
Option1:
LOOP gt_01 INTO gs_01.
gs_02-xxx = gs_01-xxx.
gs_02-yyy = gs_01-yyy.
APPEND gs_02 TO gt_02.
ENDLOOP.
UPDATE DB FROM TABLE gt_02.
Option2:
LOOP gt_01 INTO gs_01.
gs_02-xxx = gs_01-xxx.
gs_02-yyy = gs_01-yyy.
UPDATE DB FROM gs_02.
ENDLOOP.
I prefer Option2, but it needs an extra internal table and in my real problem, this table could be very large.
So does it matter if I write UPDATE in the LOOP(Option2), would it cause some DB related performance issues?
2015 Jan 14 3:50 PM
hi ming,
I think first option is better.
internal table is appended then in one go database table will be updated.
2015 Jan 14 10:44 PM
Yes is better option the First, and why you dont use Field-Symbols?
thanks
2015 Jan 15 12:58 AM
In the real problem, the logic of gs_01 and gs_02 is not that simple.
Besides, the point is not field-symbol but comparing modifying from internal table or work area.
2015 Jan 14 3:54 PM
Hi,
did you have read the Tips & Tricks from the trans. SE30 ?
regards
Fred
2015 Jan 14 4:02 PM
Using the array to update database shouldl give better performance, you should generate less communication between application server and database server.
But
Regards,
Raymond
2015 Jan 15 12:55 AM
Thanks, your reply helps.
And as far as I tried, if you insert from an internal table, you will get a dump if the internal table contains some duplicate-key records with the DB table.
However, you won't get a dump if you insert from a work area even if the key of the work area has been already existing in the DB table, you just get a sy-subrc 4 instead.
2015 Jan 15 2:54 AM
Hi Ming.
Try,
insert ztable from table itab accepting duplicate keys.
It will not display error.
Hope it Helpful.
Regards,
Venkat.
2015 Jan 15 3:45 AM
I don't know in which case we should insert duplicate key record, it breaks the rule of the database.
And I think that you can use MODIFY instead of INSERT to avoid dump.(Maybe yet the result we need)