1

In the old ABAP syntax I have to loop over the source table, and inside of the loop append value to the table.

For example:

DATA:
it_source_table type table of mara,
et_result_table type table of matnr.

loop at it_source_table into data(ls_source_table).
  append ls_source_table-matnr to et_result_table.
endloop.

Is there with a new ABAP syntax (750, 752) ("move-corresponding", "value#") a way to achieve the same in less sentences?

Suncatcher
  • 10,355
  • 10
  • 52
  • 90
Denis
  • 167
  • 3
  • 20
  • If the two tables have the same structure, and there is no condition, which lines to copy, than you never needed a loop, you ca duplicate the data in the table directly: et_result_table = it_source_table. Or do I miss something? – József Szikszai Sep 23 '21 at 08:31
  • Hi Josef, for this you can just say "move lines of it_source_table to et_result_table" or "move it_source_table[] to et_result_table[]. But this is not my case. If I need to move column A from source table to column B of result table, there is a specific move-corresponding. But in my case, I do not have column B, I have table_line instead :( – Denis Sep 23 '21 at 08:37

1 Answers1

6

You can use the VALUE operator with the FOR ... IN addition:

et_result_table = VALUE #( FOR material IN it_source_table ( material-matnr ) ).
Jonas Wilms
  • 132,000
  • 20
  • 149
  • 151