08-28-2007 3:24 AM
Hi Gurus
Can Any body explain me about HASH Tables(Advantages&disadvantages)Using this?
Thanks in advance
kalyan
08-28-2007 3:35 AM
Hi kalyan,
hash tables are sorted using Hash algorithm, so here you need not to sort it again.
kishore
08-28-2007 3:35 AM
Hi kalyan,
hash tables are sorted using Hash algorithm, so here you need not to sort it again.
kishore
08-28-2007 4:08 AM
Hi,
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.
Read this article about hashing techniques: http://en.wikipedia.org/wiki/Hash_table#Time_complexity_and_common_uses_of_hash_tables
Also check the link, here is sample code available, it will help u.
http://www.sap-img.com/abap/what-is-use-of-using-hashed-table.htm
Regards,
Priyanka
08-28-2007 4:40 AM
Hi Kalyan..
<b>Hashed Table Features:</b>
In this internal table system will not maintain the index. So we can access the records only using KEY.
Key must be always UNIQUE.
To access a record it will pass the Keyfield values to a HAsh algorithm which returns the Address of the Record.
<b>Advantages:</b>
Access time to a record is Constant in Hashed table .. So it will be efficient.
Very large internal tables can be declared as Hashed tables since Access time will not vary based on the No of records.
<b>Disadvantages:</b>
We cannot access them using index
We cannot store duplicate rows in hashed table. It will give a runtime error.
<b>Reward if Helpful</b>
09-01-2007 5:00 AM