What I’m about to show you is not exactly new. It has even been used in Abapinho before. But since there is still a lot of people out there using LOOP to change a single field of an internal table, I thought it would be worth talking about it.
Say you have an internal table with one million and two hundred thousand entries and want to change the field ICON so that it has ‘@FM@‘ in all lines.
Instead of doing this:
LOOP AT lt_data ASSIGNING <data>. <data>-icon = '@FM@'. ENDLOOP.
Try doing this instead:
ls_data-icon = '@FM@‘. MODIFY lt_data FROM ls_data TRANSPORTING icon WHERE icon <> ‘DONALD DUCK’.
You can obviously replace the condition value with any other Disney character.
Thank you Sérgio Serra for suggesting that it could be interesting talking about this. Thank you Andrew Becraft for the photo.
Greetings from Abapinho.