简体   繁体   中英

How does binary search in SAP handle duplicates?

I'm looking for an explanation of the concept of binary search in SAP. If my table has duplicates, how the search is done?

Assuming that you have already read the extensive article on binary search as well as the ABAP documentation , you will probably have overlooked the following paragraph:

If there are multiple hits (due to an incomplete search key or duplicate entries in the table), binary searches (using the BINARY SEARCH addition in standard tables; automatic in sorted tables) also return the first hit in accordance with the order of the rows in the primary index. This is the row with the lowest row number.

I believe that the binary search in abap works like the normal binary search algorithm, but after it finds a record that matches the key, it goes up the table by index until the key is different. After that if returns the first hit in the table that matches your key.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM