‎2007 Sep 05 6:09 PM
Hello Guys!
Internal table
Sorted, Hashed, Standard
For accesing itab uses,
Standard---> uses Linear Search
Sorted ---> Binary Search
Hashed-----> Hash Algorithm
Can u pls tell me what is linear search, binary search, hash algorithm?
And also,
Why we mostly go for standard table?
PLs give ur suggestions,
Thanks for your answers
<b><REMOVED BY MODERATOR></b>
Thanks
Rahul.
Message was edited by:
Alvaro Tejada Galindo
‎2007 Sep 05 6:16 PM
*Standard---> uses Linear Search
READ TABLE T_TAB WITH KEY FIELD = LS_FIELD.
*Sorted ---> Binary Search
*(Table is always sorted)
READ TABLE T_TAB WITH KEY FIELD = LS_FIELD
BINARY SEARCH.
*Hashed-----> Hash Algorithm
*Not sure...
Greetings,
Blag.
‎2007 Sep 05 6:16 PM
*Standard---> uses Linear Search
READ TABLE T_TAB WITH KEY FIELD = LS_FIELD.
*Sorted ---> Binary Search
*(Table is always sorted)
READ TABLE T_TAB WITH KEY FIELD = LS_FIELD
BINARY SEARCH.
*Hashed-----> Hash Algorithm
*Not sure...
Greetings,
Blag.
‎2007 Sep 05 6:16 PM
TABKIND - Internal Table Types
Alternatives:
1. STANDARD TABLE
2. SORTED TABLE
3. HASHED TABLE
4. INDEX TABLE
5. ANY TABLE
Effect
The table type - set in the DATA, TYPES, orCREATE DATA statement, specifies how the system accesses entries in the internal table in generic key operations.
(READ TABLE itab, DELETE TABLE itab, INSERT TABLE itab, MODIFY TABLE itab, COLLECT itab). As a general rule, the runtime required for key operations depends on the total length of the key.
The various table types have the following hierarchy:
ANY TABLE
|
-
| |
INDEX TABLE HASHED TABLE
|
-
| |
STANDARD TABLE SORTED TABLE
Alternative 1
STANDARD TABLE
Effect
Defines the table as a standard table. Key access to a standard table uses a linear search. This means that the timne required for a search is in linear relation to the number of table entries.
You should use index operations to access standard tables.
For the sake of compatibility, you can use TABLE as a synonym of STANDARD TABLE.
Alternative 2
SORTED TABLE
Effect
Defines the table as one that is always saved correctly sorted. Key access to a sorted table uses a binary key. If the key is not unique, the system takes the entry with the lowest index. The runtime required for key access is logarithmically related to the number of table entries.
You can also access sorted tables by index operations. When you insert using an index, the system checks to ensure that the sort sequence has been correctly maintained. For this reason, it takes longer than inserting entries in a standard table. As a rule, you should only access sorted tables using their key.
Alternative 3
HASHED TABLE
Effect
Defines the table as one that is managed with an internal hash procedure. You can imagine a hashed table as a set, whose elements you can address using their unique key. Unlike standard and sorted tables, you cannot access hash tables using an index. All entries in the table must have a unique key. Access time using the key is constant, regardless of the number of table entries.
You can only access a hashed table using the generic key operations or other generic operations ( SORT, LOOP, and so on). Explicit or implicit index operations (such as LOOP ... FROM oe INSERT itab within a LOOP) are not allowed.
Alternative 4
INDEX TABLE
Effect
Standard and sorted tables belong to the generic class index tables. An index table is one that you can access using an index. You can currently only use the table type INDEX TABLE to specify the type of generic parameters in a FORM or a FUNCTION. Hashed tables are not index tables, and cannot therefore be passed to parameters defined as INDEX TABLE.
Alternative 5
ANY TABLE
Effect
Like INDEX TABLE, you use ANY TABLE to specify the type of any generic table parameter. The set of permitted operations for a table with type ANY TABLE consists of the intersection of all permitted operations for STANDARD, SORTED and HASHED TABLEs, and so is identical to the set of operations permitted for hashed tables.
Note in particular that you cannot use index access for tables with this type.
‎2007 Sep 05 6:35 PM
Hi!
I want to know what is binary search, linear search, hash algorithm will do.
or whats mean by them.
Pls give specific answers.
Thanks.
‎2007 Sep 05 7:24 PM
Hi Rahul..
Let us assume that data in the internal table is sorted and take the scenario like this. We have 1 to 10 records in the internal table and we need to access the 3rd record.
Linear search: In the method search will start from the first record and progress towards the last record. whenever it reaches the required record the search will ends. The time taken for this search depends on the number of records in the internal table means time is variable.
Binary search: In this method the total records will be splitted into 2 groups. 1 group will have 1 to 5 records and other will have 6 to 10 records. Our requirement 3rd record is falling in the first half. so second half will be discarded. Now the active first half will be divided into 2 halfs. 1 to 3 will be in one group and 4 to 5 will be in another group. our requirement 3rd record is in first half. So, second half will be discarded. This procedure will be followed till it finds the required record. The time taken for search will depends on the number of records in the internal table means time for search is variable.
Hashed Alogorithm: This is an special kind of search algorithm based on the 3rd order polynomial. The specific advantage of using hashed algorithm is time for search is constant. That means, the time taken for finding out the first record and tenth record are same.
Hope this will useful for u...<b><REMOVED BY MODERATOR></b>
Regards
veerendra
Message was edited by:
Alvaro Tejada Galindo
‎2007 Sep 05 7:38 PM
Hi virendra!
Thanks for your good reply!
I want to know generally we used to go for standard internal table why?
Pls give the Answer.
<b><REMOVED BY MODERATOR></b>
Thanks
Rahul.
Message was edited by:
Alvaro Tejada Galindo
‎2007 Sep 05 10:49 PM
I use standard tables because I find them more flexible. A sorted table stays sorted by its keys. If you want it sorted in a different order, you need a separate table.
A standard table can be sorted and resorted over and over again.
Rob