2023 Nov 16 7:43 AM
Hello everyone,
Could you please help me?
I have an Internal table with huge items and many fields and I want collect some of those fields avoiding use of loop.
I want to replace this instruction:
Loop at <itab1> assigning field-symbols(<fs1>)
Move-Corresponding <fs1> to field-symbols(<fs2>)
Collect <Fs2> into Itab_2.
Endloop.
Since Itab1 has a lot number of records and itab2 has a lot number of columns I wouldn't use Loop.
I read about REDUCE operator but I don't want specify all fields of itab2.
Anyone can help me with a code?
Thank you in advance
2023 Nov 16 1:59 PM
Your argument is wrong. REDUCE does a FOR loop anyway, it's equivalent to LOOP AT performance.
The reason I would rewrite your code is because of MOVE-CORRESPONDING because it's very difficult to understand the goal of the developer, and a change in the types may change the behavior of this code without warning.
2023 Nov 16 2:25 PM
Sorry Sandra, I try to explain better my goal.
I would like to know if, with new abap code, there is an instruction to replace the old collect instruction and to avoid use of loop.
With old abap code for collecting data from a table into another one the code was:
Loop at internal_table_source into work_area_source.
Move-corresponding work_area_source to work_area_target.
Collect work_area_target into Internal_table_target.
Endloop.
Since I have a huge number of records from internal_table_source I was wondering if I can use new instructions to avoid loop..endloop statement to collect those records into internal_table_target.