Application Development and Automation 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: 
Read only

Binary search

Former Member
0 Likes
532

Hi Experts,

My question is, Is it possible to use binary search for a fileld which is blank.

sort it_mhis by warpl abnum knasr.

read table it_mhis into wa_mhis

with key warpl = wa_afih-warpl

abnum = wa_afih-abnum

knasr = ' '. " (Balank)

binary search.

if the above statment is wrong ,i would like to know why??

Regards,

Amit

1 ACCEPTED SOLUTION
Read only

former_member156446
Active Contributor
0 Likes
475

its just the sort sequence that matters.. nothing to do with the data in the internal table..


sort it_mhis by warpl abnum knasr.
read table it_mhis into wa_mhis with key warpl = wa_afih-warpl
                                                            abnum = wa_afih-abnum
                                                            knasr = ' '. " (Balank)
                                                            binary search. 
if sy-subrc eq 0.

endif.

3 REPLIES 3
Read only

former_member156446
Active Contributor
0 Likes
476

its just the sort sequence that matters.. nothing to do with the data in the internal table..


sort it_mhis by warpl abnum knasr.
read table it_mhis into wa_mhis with key warpl = wa_afih-warpl
                                                            abnum = wa_afih-abnum
                                                            knasr = ' '. " (Balank)
                                                            binary search. 
if sy-subrc eq 0.

endif.

Read only

Former Member
0 Likes
475

Hi,

It is possible, no issues. Binary search addition in read statement works properly only when the internal table sorted with key fields used in the condition of the read.

Regards,

Muthu.

Read only

Former Member
0 Likes
475

It will depend upon the content of the internal table if whole column for a field is empty and it is the only key to read the table it will not work.

Looking at this case it will work as this is one of three keys avilable.

As a whole if a key can identify a unique record from an internal table binary serch will work otherwise not.

Regards

Bikas