Performance question - Appending internal table

Question:
Hi
I try to optimize my code, but I can't find the right statement:
My old code:
        loop at l_tt_cofi_lines where tarsystem = 'EBD'.
          move:
          g_yybc0004_tab1-trkorr to g_yybc0004_tab2-trkorr,
          g_yybc0004_tab1-owner to g_yybc0004_tab2-owner1,
          l_tt_cofi_lines-trdate to g_yybc0004_tab2-rdate1,
                 l_tt_cofi_lines-trtime to g_yybc0004_tab2-rtime1,
                         '4' to g_yybc0004_tab2-place.
          append g_yybc0004_tab2.
          clear g_yybc0004_tab2..
          exit.
        endloop.
My suggest to new code (but syntax check is not OK)
        append lines of l_tt_cofi_lines to g_yybc0004_tab1
        where tarsystem = 'EBD'.
Any suggest ??
Answer:
itab_target[] = itab_source[].
delete itab_target where tarsystem = 'EBD'.
Best Wishes
Jawahar
Answer:
Thanks, but what about the:
'4' to g_yybc0004_tab2-place.
Answer:
Take a look at F1 on MODIFY. There youŽll find how to modify multiple lines in 1 statement.
And I guess JahawarŽs code should be: ...tarsystem NE 'EBD'.
Besides that, Lasse, I think your old and new code do totaly different things. The old code copies only 1 record (if no 'EBD'is found only 0), while the suggested new code is capable of copying multiple lines.
Answer:
Thanks ocvantol, is right in all respects. Sorry I forgot this aspect while posting the reply.
Option 1 If u want all records
itab_target[] = itab_source[].
delete itab_target where tarsystem ne 'EBD'.
As '4' is common for all lines anytime later when you loop itab_target you can force/pass this.
Option 2 If u want 1 record
Use read statement with / without binary search should be the ideal one.
instead of a loop statement
(For Binary Search should be sorted accordingly, probably u r aware)
Then use a modify statement
Jawahar

More Articles:

problem with a select?
FTP: AB_RFC_X_SCRAMBLE_STRING problem?
printing reports in landscape page format?
BDC Problem with VL02N?
pls help. REPLACE function?
Help with Date Logic?