INSERT and APPEND with ASSIGNING FIELD-SYMBOL
The harsh truth, at all costs, is that structures are out of date. Nowadays FIELD-SYMBOLS are in.
When you make a LOOP to an internal table of course that you also use ASSIGNING FIELD-SYMBOL instead of INTO Structure,correct?
But what was screwing everything over was APPEND and INSERT. I did not know how to use a structure to add records
Because of that, until a few days ago, I was still doing something like this:
DATA: T_ABC TYPE STANDARD TABLE OF ZABC,
W_ABC LIKE LINE OF T_ABC.
W_ABC-XYZ = 'Olá'.
APPEND W_ABC TO T_ABC.
Which was a pity because, there you go, using structures…well…it’s like still having Windows 7 when Windows 8 is already out more than a week ago. Or like still listening to Madonna now that Lady Gaga exists. Or even listening to Lady Gaga now that Die Antwoord exists.
But everything changed when recently Sérgio Fraga showed me that after all you can use FIELD-SYMBOLS with INSERT and APPEND:
DATA: T_ABC TYPE STANDARD TABLE OF ZABC.
FIELD-SYMBOLS: <ABC> LIKE LINE OF T_ABC.
INSERT INITIAL LINE INTO TABLE T_ABC ASSIGNING <ABC>.
<ABC>-XYZ = 'Olá'.
Thank you Sérgio Fraga because this is so good, and I mean so good, that it feels like finding a table needed for register/records to be inserted to go and use this right now.
Thank you mscaprikell for the photo.
Greetings from Abapinho.