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
729

hi Experts!

we r using read statement in a loop with binary search, but data is not coming. when we removed binary search, data is coming.

if help me out .

regards,

Rahul

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
705

Hi Rahul,

Use SORT before using Binary Search.

REward if useful!

6 REPLIES 6
Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
705

Hi,

SORT the table before you use BINARY SEARCH In READ.

SORT ITAB BY ....

READ TABLE ITAB .......... BINARY SEARCH.

This is needed if your table is of type STANDARD, not required if it is SORTED and cannot use if it is HASHED.

Regards,

Sesh

Read only

0 Likes
705

Its depends on Wat data ur fetching into internal table.

If its item data it happens like that.

So before using binary search sort it and delete adjacent duplicates.

Regards'

Sreenivasa Reddy.

Read only

Former Member
0 Likes
706

Hi Rahul,

Use SORT before using Binary Search.

REward if useful!

Read only

0 Likes
705

Hi ,

USe sort statement befor you start binary search

and for further info use this link,

http://en.wikipedia.org/wiki/ABAP

If useful reward points.

Thanks

Sanket.

Read only

Former Member
0 Likes
705

Hi Rahul,

You need to sort the internal table before the loop when you are using BINARY SEARCH

You have to sort those fields which u r using in where condition for the READ statement

Read only

S0025444845
Active Participant
0 Likes
705

Hi,

1) sort the table outside the loop which u r reading.

2) sort the table with keys by which u r reading the table in the same sequence.

like

SORT: p_it_vbkd BY vbeln posnr,

p_it_t001 BY bukrs,

p_it_vbkd1 BY vbeln posnr,

p_it_vbrp BY vbeln.

LOOP AT p_it_out INTO lw_out.

READ TABLE p_it_vbrp

INTO lw_vbrp

WITH KEY vbeln = lw_out-vbeln1

BINARY SEARCH.

  • If aubel is not intial

IF NOT lw_vbrp-aubel IS INITIAL.

  • Get exchange rate from it_vbkd for a line item

READ TABLE p_it_vbkd

INTO lw_vbkd

WITH KEY vbeln = lw_vbrp-aubel

posnr = lw_vbrp-posnr

BINARY SEARCH.

regards,

sudha