Denis
Denis

Reputation: 167

A short syntax to fill ABAP table from another table?

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?

Upvotes: 1

Views: 20061

Answers (1)

Jonas Wilms
Jonas Wilms

Reputation: 138567

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

et_result_table = VALUE #( FOR material IN it_source_table ( material-matnr ) ).

Upvotes: 7

Related Questions