2010 Dec 05 4:20 PM
Hi,
I have the following issue:
From a table, I am picking up 5 fields into an internal table (in the correct sequence):
A B C D E.
Now, I am sorting the above internal table as follows:
sort itab by A B C descnding.
Now, I am writing the read stmt as follows:
read table itab into wa_itab with key
A = var1
B = var2
C = car3
Binary Search.
But, the read fails in most of the cases even though the exact values exist in the itab. It does not fail always, but fails for majority of the cases, though the exact matches are present in the itab.
If I remove the Binary Search option, it works fine.
Could you please let me know if I am missing out on anything here?
Please let me know if any more information is needed.
Thank You,
Anjana Banerjee
2010 Dec 06 7:14 AM
Sort in Descending order does not give the correct results when using read with binary search. You need to sort it in the ASCENDING order to use binary search.
2010 Dec 06 6:51 AM
I remember in one of the thread Thomas Zloch saying that binary search must be sorted in ascending order.
Its correct the binary search algorithm divides the data into segements and searched from left to right. If its in descending order your binary search will fail in the first rule itself. ( Remember the traversal is always left to tight )
2010 Dec 06 7:14 AM
Sort in Descending order does not give the correct results when using read with binary search. You need to sort it in the ASCENDING order to use binary search.
2010 Dec 06 7:59 AM
Hi anjana,
please do not ask questions before reading the online help:
["The standard table must be sorted in ascending order by the specified search key. "|http://help.sap.com/saphelp_nw73/helpdata/en/fc/eb373d358411d1829f0000e829fbfe/frameset.htm]
Regards,
Clemens