‎2006 Sep 13 9:13 PM
‎2006 Sep 13 9:14 PM
Hi Tom,
The binary search algorithm helps faster search of a value in an internal table. It is advisable to sort the internal table before doing a binary search. Binary search repeatedly divides the search interval in half.
If the value to be searched is less than the item in the middle of the interval, the search is narrowed to the lower half, otherwise the search is narrowed to the upper half.
Not Recommended
Read table int_fligh with key airln = 'LF'.
Recommended
Read table int_fligh with key airln = 'LF' binary search.
Hope this will help.
Regards,
Ferry Lianto
‎2006 Sep 13 9:14 PM
Basically it uses the binary search logic to find the exact match. In short, it uses the binary search logic to find the exact record from the internal table.
Message was edited by: Anurag Bankley
‎2006 Sep 13 9:14 PM
Hi Tom,
The binary search algorithm helps faster search of a value in an internal table. It is advisable to sort the internal table before doing a binary search. Binary search repeatedly divides the search interval in half.
If the value to be searched is less than the item in the middle of the interval, the search is narrowed to the lower half, otherwise the search is narrowed to the upper half.
Not Recommended
Read table int_fligh with key airln = 'LF'.
Recommended
Read table int_fligh with key airln = 'LF' binary search.
Hope this will help.
Regards,
Ferry Lianto
‎2006 Sep 13 9:14 PM
Hi,
When you specify the binary search it uses this search technique with the fields given in the with key option.
The fields that you specify in the with key option needs to be sorted in the order in which you specify..
Thanks,
Naren
‎2006 Sep 13 9:15 PM
Hi,
WITH KEY = dobj [BINARY SEARCH]
Effect:,If the addition WITH KEY is followed by a single data object after an "equals" sign, the first line found in the internal table itab is read, whose whole content corresponds to the content of the data object dobj. It must be possible to convert the data object dobj to the line type of the internal table. If the data type of dobj does not correspond to the line type of the internal table, a conversion is performed for the comparison according to the conversion rules.
Regards,
Azaz Ali.
‎2006 Sep 13 9:15 PM
Hi
It can improve the peformance of READ TABLE statament because a "Binary" strategy is used to read the internal table, but to use this option the table has to be sorted.
SORT ITAB by FIELD1 FIELD2 .... FIELDN
READ TABLE ITAB WITH KEY FIELD1 =
FIELD2 =
.................................
FIELDN =
binary search.
Max
‎2006 Sep 13 9:18 PM
Hi Tom,
For binary search, you basically sort the internal table first.
Then the internal logic for binary search is that program splits internal table into 2 parts and does match in first part. If required key is not found, then the other half is used for search so in short you are splitting the internal table for lookup. This increases the performance of search and lookup.
Cheers,
Vikram
Please reward for helpful replies!!
‎2006 Sep 13 9:25 PM
Hi Tom,
1) BINARY SEARCH clause with READ statement improves the performance.
2) You need to SORT the internal table with specific fields before using BINARY SEARCH clause with READ statement
3) Otherwise, it leads to improper results
To know more about READ statement with BINARY SEARCH clause, browse this link
http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/read_t01.htm
Thanks,
Vinay