‎2005 Jun 16 6:39 AM
What is Hash Table And how it is different from Standared Table and Sorted Table and How it is Used or defined.
‎2005 Jun 16 6:57 AM
Hi,
Just go thro' this.
1. Types of internal tables
1.1 STANDARD table
Key access to a standard table uses a linear search. This means that the time required for a search is in linear relation to the number of table entries.
You should use index operations to access standard tables.
1.2 SORTED table
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.
1.3 HASHED table
Defines the table as one that is managed with an internal hash procedure
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.
1.4 INDEX table
A table that can be accessed using an index.
Index table is only used to specify the type of generic parameters in a FORM or FUNCTION. That means that you can't create a table of type INDEX.
Standard tables and sorted tables are index tables.
1.5 ANY table
Any table is only used to specify the type of generic parameters in a FORM or FUNCTION. That means that you can't create a table of type ANY.
Standard, sorted and hashed tables belongs to ANY tables.
‎2005 Jun 16 7:00 AM
Hi Mithlesh,
A hased table is the kind of an internal table which is closest to a database table.
The fundamental difference is that the entries in a hashed table cannot be accessed through an index.
For example, the following statement is not applicable to a hashed table -
READ TABLE ITAB INDEX <n>.If you notice, even in case of a database table, let us say, SPFLI, we cannot say, "get me the 10th record of the table SPFLI". The entries can only be retrieved by specifying a "key". So you would have something like -
READ TABLE ITAB WITH KEY....This is similar to a SELECT statement that we use for a database table. We specify the key fields in the WHERE condition.
Obviously, a hashed table has to have a KEY, and cannot have duplicate entries for the key fields. Which is again just like in case of a database table.
And finally, even though it is only used rarely, in some cases using a hashed table can improve the performance significantly - the reason being that the time required to fetch any record from a hashed internal table is constant.
Hope that is clear. If not, please get back.
Regards,
Anand Mandalika.