Unexpected performance finding with MOVE-CORRESPONDING between table and structure variant
During some tests with a huge amount of data a a colleague of me Dirk Freundel gets unexpected performance finding between:
- MOVE-CORRESPONDING struc1 TO struc2
- MOVE-CORRESPONDING itab1 TO itab2
He put 1.000.000 lines of a table with 27 columns into a internal table with 16 columns. Variant 1 needed about 179 ms less time than variant 2.
Test code:
DO 10 TIMES.
* Init
FREE lt_middle.
* Runtime
GET RUN TIME FIELD lv_runtime_a.
* LOOP
LOOP AT lt_database ASSIGNING <fs_database>.
MOVE-CORRESPONDING <fs_database> TO ls_middle.
INSERT ls_middle INTO TABLE lt_middle.
ENDLOOP.
* OR TABLE
"MOVE-CORRESPONDING lt_database TO lt_middle.
* Runtime
GET RUN TIME FIELD lv_runtime_b.
lv_runtime_b = ( lv_runtime_b - lv_runtime_a ) / 1000.
WRITE: / SY-INDEX, ' Runtime [msec]: ', lv_runtime_b.
ENDDO.
Has anybody else observed the same performance finding, Please add a comment.
Hi Florian .Your code kind of confuses me .To me itab1 itab2 struc1 struc2 are the same things .They are all work area. Maybe it's coincidence ??^^
Hi Eyann,
I came to this when I had the requirement to copy data from itab1 (lt_database) to itab2 (lt_middle). lt_database has 27 fields, lt_middle just has 16 fields. So there are two possibilities:
I think the "MOVE-CORRESPONDING itab1 TO itab2" is a rather new ABAP command, while "MOVE-CORRESPONDING struc1 TO struc2" is very old - so I thought/ hoped that the new command has performance advantages over the old LOOP & MOVE...