Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

New Syntax for Collect

Pier_1973
Participant
0 Kudos
887

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

2 REPLIES 2

Sandra_Rossi
Active Contributor
0 Kudos
814

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.

Pier_1973
Participant
0 Kudos
814

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.