Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

binary search

Former Member
0 Kudos

hi dar

i want to write..

read itab1 into wa_itab1 with key field4 binary search.

for this shud i sort the itab1 by field4 ?

3 REPLIES 3

former_member181962
Active Contributor
0 Kudos

Yes. you should.

Former Member
0 Kudos

hi TUBORG,

yes it is prerequisite to sort the table by field which is used in binary search

SORT ITAB1 BT  FIELD4.
read itab1 into wa_itab1 with key field4 eq v_field4 binary search.

Former Member
0 Kudos

Hi Tuborg ,

You need to sort the internal table with the field field4 , as this is mandatory when you use binary search .

The reson being binary search finds the record in the middle and checks if the value is less that the value we are searching for , if it is then it searches from the first record to this record and so on.

So if we do not sort the table then we may miss out the redcord we are searching for

Regards

Arun