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 does not work as before after upgrade

Former Member
0 Likes
1,546

We recently upgraded from HRSP 26 to HRSP 40 as well as similar upgrades in non-HR areas on our ECC 6.04 system. We've been in SAP since 1998, and have a lot of old custom programs which were written when we were still new at ABAP. In a few, we put records into an internal table sorted the table, maybe added a few more records to the table, and did a READ BINARY SEARCH. Granted, this is not correct, adding records to a table after it is sorted. But these programs have worked for more than 10 years and now, since our upgrade, the READ BINARY SEARCH does not always find a record where it did before the upgrade.

So this is mostly just a heads-up. If you are missing data in reports after upgrading, this might be the issue. Also I am wondering if anyone has experienced this.

Heads-up!

Janice Ishee

8 REPLIES 8
Read only

Kartik2
Contributor
0 Likes
1,370

hi,

one of the pre-requisites to use binary search is that the internal table should be sorted prior to using binary search in read statement. Please make sure that the internal table is sorted befor you use the Binary search statement.

Regards,

kartik

Read only

Former Member
0 Likes
1,370

Hi,

One primary pre-requisite for BINARY SEARCH is that you have to sort internal table which field you want to read from table.

With Regards,

Jayvin

Read only

Former Member
0 Likes
1,370

The entire concept of Binary search is splitting the array(tale in this case) into two part(always), a lower value part and a upper value part, and it keeps doing that till it finds value.

So IT WILL NEVER WORK without SORT that too ONLY when the table is sorted in ASCENDING ORDER.

sort is descending and it wont work.

so, forget about what was there... see what you can do on that

Read only

Clemenss
Active Contributor
0 Likes
1,370

Hi Janice,

you did not give any context. Please note that it is a popular error to think that a SELECT statement will fetch data in order of the primary key of the table - although it happens quite frequently. So always first sort, then binary search.

Probably not related to upgrade.

Regards,

Clemens

Read only

Former Member
0 Likes
1,370

This is just a heads-up to anyone that might be having the same problem. BINARY SEARCH was more forgiving before we installed HRSP's 27-40 and other related service packs. Programs that worked for 12 years, even though BINARY SEARCH was occassionally not used by us correctly, are now not working. Just f.y.i.

Read only

matt
Active Contributor
0 Likes
1,370

I see. A heads-up to warn people if they've not been using BINARY SEARCH as it's supposed to be used, that they might encounter problems now.

Just goes to show what problems programming by coincidence can cause! (I.e. it works, so that's what matters).

Edited by: Matt on Jan 9, 2012 2:02 PM - removed a comment that was a bit harsh!

Read only

Former Member
0 Likes
1,370

programming by coincidence

A nice turn of phrase

I think we are all guilty at some time though.

Rob

Read only

matt
Active Contributor
0 Likes
1,370

Not original to me. I first encountered it in "The Pragmatic Programmer".