Skip to Content
0
Nov 12, 2022 at 07:19 PM

How to move one column from one internal table to another using VALUE/BASE/FOR?

790 Views

Hello,
I have an internal table storing some of the customer's data and I want to append a column from another table which stores e-mail addresses. LIFNR is the common field between tables.
I have the function itself already working:

LOOP AT gt_email_addr INTO gwa_email_addr.
LOOP AT gt_main INTO gwa_main.
IF gwa_main-lifnr = gwa_email_addr-lifnr.
gwa_main-smtp_addr = gwa_email_addr-smtp_addr.
MODIFY gt_main FROM gwa_main.
ENDIF.
ENDLOOP.
ENDLOOP.

BUT I would prefer it to work as a FOR loop. At the moment I am trying something like this:

gt_main = VALUE #( BASE gt_main FOR wa IN gt_email_addr ( CORRESPONDING #( wa ) ) ).
But it doesn't work - the line above actually just appends a new record to gt_main. The documentation seems to be very "tip-of-the-iceberg" about it and provides just some theory and all other sources explain how I can use such a loop to add literal values provided within the code instead and I can't find anything about moving data from one table to another in this way.
Of course, I also tried different versions of that statement, e.g. using WHERE clause (trying to connect those LIFNRs), but, apparently, wa has no such field.

Any ideas what I am doing wrong? It kind of feels like I "just" need to approach the BASE part differently, but nothing seems to work.

Kind Regards,
Bartosz