Monday, August 22, 2016

SORT, BINARY SEARCH

Binary Search:

Binary Search is used to make the searching faster. The internal table does need to be sorted according to the specified search key(s) before performing the binary search.


sort i_mara by matnr descending ersda descending.
read table i_mara with key matnr = condition 1
                                           ersda = condition 2
                                    binary search.

The search runs as follows for the individual table types, without BINARY SEARCH being specified:
  • Standard tables are searched in a linear fashion.
  • Sorted tables are sorted in a binary fashion if the specified search key is an initial part of the primary table key or includes this key; otherwise the search is linear.
  • The hash algorithm is used for hashed tables if the specified search key is an initial part of the primary table key or includes this key; otherwise the search is linear. 
How binary search is performed?
In computer sciencebinary search, also known as half-interval search[1] or logarithmic search,[2] is a search algorithm that finds the position of a target value within a sorted array.[3][4] It compares the target value to the middle element of the array; if they are unequal, the half in which the target cannot lie is eliminated and the search continues on the remaining half until it is successful.
Binary search into array.png



No comments:

Post a Comment

SAP giới thiệu mã hỗ trợ AI trong ngôn ngữ ABAP riêng của mình

SAP đã ra mắt một loạt tính năng mã hỗ trợ AI trong môi trường phát triển ứng dụng dựa trên đám mây của mình, đồng thời tham gia vào danh sá...