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 |
Explain what are the problems in processing batch input sessions?
What’s value table?
Can you create a table with fields not referring to data elements? : abap data dictionary
In material report output,if i click on any material i have to open MM01 with that material in the field how?and from mm01 screen i have to come out what i have to do?
Explain the call transaction method? : abap bdc
What are system variable in abap?
what is the standard program to transport transaction variants and screen variants?
diff types of BAPIS?
what is the model dialog box?
1 Answers Bristle Cone, Cap Gemini, HP, Satyam, Wipro,
WHAT IS DATA DICTIONARY?? AND WHICH OBJECT IN DATA DICTIONARY???
How are the function code handles in flow logic?
what is search help exit ????