SELECT... INTO CORRESPONDING FIELDS OF TABLE
Let's say I did one SELECT using INTO CORRESPONDING FIELDS OF TABLE itab.
Let's consider the table I selected from had the fields A, B, and C.
Now let's assume I do another select, now using FOR ALL ENTRIES, because I need the previous populated internal table - but now I'm selecting from a table that contains fields B, C and D.
Assuming my destination table itab is made of a structure of A, B, C and D, is it expected at the end that I whatever values I might have had for field A I lose them, because the 2nd select was made against a table that doesn't have it ?
Because that's what is happening, and I would like to keep the values of A the 1st query brought me. But when I execute the 2nd query, it brings new rows - ok - but all the values I had for field A, which doesn't exist in this table in the FROM clause in the 2nd select, get erased.
Is there a way to prevent this from happening ?
In terms of code:
TYPES: BEGIN OF ty_zcar, vbeln TYPE likp-vbeln, exidv TYPE vekp-exidv, venum TYPE vekp-venum, END OF ty_zcar, tt_zcar TYPE STANDARD TABLE OF ty_zcar. DATA: gt_zcar TYPE tt_zcar. SELECT * FROM likp INTO CORRESPONDING FIELDS OF TABLE lt_zcar WHERE likp~vbeln = p_vbeln. CHECK lt_zcar IS NOT INITIAL. "so the select below doesnt do a cross join with table lips SELECT * FROM lips INNER JOIN vepo ON vepo~vbeln = lips~vbeln AND vepo~posnr = lips~posnr INTO CORRESPONDING FIELDS OF TABLE gt_zcar FOR ALL ENTRIES IN lt_zcar WHERE lips~vbeln = lt_zcar-vbeln. lt_zcar = gt_zcar. SELECT exidv FROM vekp INTO CORRESPONDING FIELDS OF TABLE gt_zcar FOR ALL ENTRIES IN lt_zcar WHERE vekp~venum = lt_zcar-venum.
What happens is that VEKP doesn't have the field VBELN, while all the others above the last select do, but I'm losing the values I got at so far at the end.