Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

what is a binary search ? and how it is useful in a sorted
internal table ?

Answer Posted / shweta upadhyay

Definition: Search a sorted array by repeatedly dividing
the search interval in half. Begin with an interval
covering the whole array. If the value of the search key is
less than the item in the middle of the interval, narrow
the interval to the lower half. Otherwise narrow it to the
upper half. Repeatedly check until the value is found or
the interval is empty.

SYNTAX : READ TABLE <itab> WITH KEY <k1> = <f1>... <kn> =
<fn> <result>

BINARY SEARCH.

CODE :
REPORT demo_int_tables_read_index_bin.

DATA: BEGIN OF line,
col1 TYPE i,
col2 TYPE i,
END OF line.

DATA itab LIKE STANDARD TABLE OF line.

DO 4 TIMES.
line-col1 = sy-index.
line-col2 = sy-index ** 2.
APPEND line TO itab.
ENDDO.

SORT itab BY col2.

READ TABLE itab WITH KEY col2 = 16 INTO line BINARY SEARCH.

WRITE: 'SY-SUBRC =', sy-subrc.

The output is:

SY-SUBRC = 0

The program fills a standard table with a list of square
numbers and sorts them into ascending order by field COL2.
The READ statement uses a binary search to look for and
find the line in the table where COL2 has the value 16.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are client dependent objects in abap/sap?

1100


What is the use of at new statement ?

1793


How to transfer the objects? Have to transferred any objects?

1056


What is an internal table?

1189


B -Credit Note report Selection Screen Ranges: Creation date Sales Org Sold to Party Selection condition: Document Category – VBTYP should be ‘O’ Table to be used: VBRK, VBRP,VBPA,ADRC List the CR order types or credit billing type by customer number (or selected customer) and displays the: - Billing Document date (FKDAT) - Customer number (KUNRG) - Name of the reseller (on top of the SAP No) (NAME1) - Billing document number,(VBELN) - order reason (AUGRU_AUFT) - Amount (NETWR) - Currency (WAERK) Group Currency wise, billing type wise sum of Net value. When user double click on field ‘Billing Document #’ , display the document in VF03 Do this using OO ABAP.

3021


What is abap dictionary or data dictionary? What is the transaction to access abap dictionary? : abap data dictionary

971


What is static attribute

1582


What are the page headers for secondary lists?

1045


How to combine multiple order in one Delivery ( Step by Step)?

2405


what are the problem we face during development( if we say v are in support(development)? what are the critical problems araises during LSMW updation and Smart form layout development for involce and po? very very important questions now a days commonly asking..plz plz reply me

2032


how to Create reports in SD module such as sales order report, which covers all organization levels, delivery status, invoice status, shipping details and partner function details. The data will be extracted from VBAP, VBPA, VBAK, VBUP, VBFA, KNA1, LIPS, VBRP, MARA, VBEP and KONV tables. plz mention the detail coding Tahnks, Rahul

3341


What are the features of abap/4 dictionary? : abap data dictionary

1069


what is diff between idocs,bdc,rfc and bapi. give real time answer

19628


Which database object is used for storing the system variables? : abap data dictionary

1403


What are null values?

1014