Performance: The optimal way to change the content of internal table
In ABAP we can update the content of internal table at least by two ways:
1. Pass over the internal table with LOOP-AT statement, assign the iteration value to FIELD-SYMBOL pointer and update the desired attribute of the structure.
2. Use MODIFY statement for internal table with TRANSPORTING-WHERE addition.
The question is what way is more optimal from performance point of view for large and short tables.
It will be great if some theoretical explanation will be supplied, why exactly this way is better, than the other one.
I tried to check the subject in Tips & Tricks of SE30, but I'm not sure, that these results are statistically reliable.
Looking at the code the statement
Always performs better when the internal table is a Hashed Type. But if its not I think it will be at par with the other one as it will have to end up evaluating all the lines to check the the field contents = «EN-US». Basically the Modify statement with hashed itab will help you get to your entries faster compared to a line-by-line check.
Also the variations can only be prominently visible only when a very large dataset is in consideration and also the variety of data involved say in a pool of 100000 records you have just one entry with «EN-US». then that means 99999 false iterations in a LOOP..ENDLOOP construct wasted CPU cycles. In such a case a Hashed table would search the entries quiet quickly using less CPU cycles. A hashed search is always quicker than a linear search.