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

Difference between read table with & without Binary search

Former Member
0 Likes
1,873

Let me know about read table with Binary search and read table without Binary search

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,084

BINAY SEARCH in READ will definitely increase performance.But you need to SORT the internal table with all fields specifying in your READ statement.

Use the following statement before READ statement with BINARY SEARCH.

SORT TKOMV BY KNUMV KPOSN KSCHL.

READ TABLE TKOMV WITH KEY KNUMV = GT_VBAK-KNUMV

KPOSN = GT_VBAP-POSNR

KSCHL = 'PR00'

BINARY SEARCH.

binary search is one of the fastest way to find the record exists in the internal table.

TO use BINARY SEARCH, you have to SORT the internal table in ASCENDING/DESCENDING ORDER. Then only you will get the exact results.

For more detail you can refer to below threads:

5 REPLIES 5
Read only

Former Member
0 Likes
1,085

BINAY SEARCH in READ will definitely increase performance.But you need to SORT the internal table with all fields specifying in your READ statement.

Use the following statement before READ statement with BINARY SEARCH.

SORT TKOMV BY KNUMV KPOSN KSCHL.

READ TABLE TKOMV WITH KEY KNUMV = GT_VBAK-KNUMV

KPOSN = GT_VBAP-POSNR

KSCHL = 'PR00'

BINARY SEARCH.

binary search is one of the fastest way to find the record exists in the internal table.

TO use BINARY SEARCH, you have to SORT the internal table in ASCENDING/DESCENDING ORDER. Then only you will get the exact results.

For more detail you can refer to below threads:

Read only

anversha_s
Active Contributor
0 Likes
1,084

hi,

If the addition BINARY SEARCH is specified, the search is binary instead of linear.

This considerably reduces the runtime of the search for larger tables (from approximately 100 entries upwards).

For the binary search, the table must be sorted by the specified search key in ascending order.

Otherwise the search will not find the correct row.

Regards

Anver

Read only

0 Likes
1,084

Hi,

Just want to know how to post a question here?

I'm only new in this community.

Thanks and regards,

Larissa

Read only

0 Likes
1,084

Larissa,

Welcome to SCN.

first choose the right place to post your query so that can get quality of answers.

just from you home screen of SDN:

Forums>Choose correct Forum Categories>you will be abale to see Post New Thread there>here you can post your query.

Also i would also suggest you to read [Rules Before posting|https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/rulesofEngagement]

Happy posting

Cheers

Read only

Former Member
0 Likes
1,084

Also, U need to SORT....

Before using Binary search Sort the internal Table.

SORT TABLE TKOMV BY KNUMV KPOSN KSCHL.

READ TABLE TKOMV WITH KEY KNUMV = GT_VBAK-KNUMV

KPOSN = GT_VBAP-POSNR

KSCHL = 'PR00'

BINARY SEARCH.