First of all I would like to say that this is partly because Sharad Agrawal replied to my previous blog entry on “internal table – fill and read”. I thought about this previously, but after Sharad Agrawal asked about it I thought that it might be a good idea to check on “loop at itab where” more thoroughly.
Simple things first – no replacement
Replacement in sorted tables
Some additional words on the READ BINARY SEARCH in case you have a somehow sorted table: Did you see that I didn’t jump to a line with full specified key? I jumped to a line which does not exist. If you call READ BINARY SEARCH with a key which does not exist, the SY-TABIX points to the line where the entry should be located. So if you want to jump to the first entry in a table which has some attributes, you might use the READ TABLE … WITH KEY sortfield1 = v1 sortfield2 = SPACE BINARY SEARCH (of course space only if it’s a char field…)