what is a binary search ? and how it is useful in a sorted
internal table ?
Answer / 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 |
What is ITS? What are the merits of ITS?
hi my name is amit i have passed BE(CSE) with honours(72%) in 2006 yr. i have completed SAP/ABAP training with good exposer. i need a staffing company which can provide me real time exposer in SAP R/3. so plz help me out and send any information regarding on my mail id or tele. no. 9999784331 thanks
What are internal tables? How to use a specific number occurs statement?
y we need SSF_FUNCTION_MODULE IN SMARTFORMS?
how can we do performance tuning after coding?
What is tmg?
How to find Buffered or not?
2 Answers Cap Gemini, Unilogic Software, Visa Steel,
How did you handle errors in Call Transaction?
what is the diffreence between sap memory and abap memory plz give the example
A subroutine can be terminated unconditionally using exit. State true or false : abap modularization
Explain the differences between se01, se09 and se10?
which state ment is used to move identically named fields between structures?