‎2009 Jul 16 4:39 AM
I have an Internal Table as below
Value Description
100 Product
2008 Production Year
05 Production Month
I am using Read statement with Binary Search for getting Production Month.
Read table itab with key Description = 'Production Month' binary search.
I am getting sy-subrc as 4 eventhough data is present in the table for Production Month.
What may be the problem.
‎2009 Jul 16 4:44 AM
You have to sort the table by the KEY before using BINARY SEARCH.
say ur internal table is ITAB and you want to search with key PDATE,
then do SORT ITAB by PDATE.
then do.. READ TABLE ITAB .. WITH KEY PDATE = ... BINARY SEARCH.
‎2009 Jul 16 4:44 AM
You have to sort the table by the KEY before using BINARY SEARCH.
say ur internal table is ITAB and you want to search with key PDATE,
then do SORT ITAB by PDATE.
then do.. READ TABLE ITAB .. WITH KEY PDATE = ... BINARY SEARCH.
‎2009 Jul 16 4:45 AM
Hi,
First Sort the itab with Description field, then use the READ statement,
For BINARY SEARCH to be used, we have to sort the internal table before with the order of WHERE clause in READ statement.
Regards
Bala Krishna
‎2009 Jul 16 4:47 AM
SORT internal table before you use BINARY SEARCH is the thumb rule.
Thanks
Kiran
‎2009 Jul 16 4:50 AM
Hi suganya,
use
sort table itab ascending by <production month>.
Read table itab with key description = <production month> binary search.
Remember always, while using binary search always sort the internal table.
Regards,
Sakthi.