Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

hash tables

Former Member
0 Likes
624

hi experts,

can anyone tell me the answer of two questions on hash tables

1> what are the problems of using hash tables

2>what are the advantages of using hash tables

thanks and regards,

nikesh kumar

4 REPLIES 4
Read only

Former Member
0 Likes
570

Hi,

You cannot access a hashed table using its index.

Hashed tables are useful if you want to construct and use an internal table which resembles a database table or for processing large amounts of data.

Hope this helps.

Reward if helpful.

Regards,

Sipra

Read only

Sm1tje
Active Contributor
0 Likes
570

1. Should have a unique key. So if you're selecting data with possible duplicate entries, a short dump will occur. Is a matter of defining the key correctly.

2. Performance wise, especially in internal table with lots of entries, time for determining certain entry will be the same (will not increase with number of entries in internal table).

Read only

Former Member
0 Likes
570

Hi

This is the most appropriate type for any table where the main operation is key access. You cannot access a hashed table using its index.

The response time for key access remains constant, regardless of the number of table entries. Like database tables, hashed tables always

have a unique key. Hashed tables are useful if you want to construct and use an internal table which resembles a database table or for

processing large amounts of data.

Read only

Former Member
0 Likes
570

Hi Kumar,

Hashed table is useful when your have to work with very big internal table and to read it with

"READ TABLE WITH KEY ..."

The time access is constant !

Definition of a Hashed Table:

"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 to INSERT itab within a LOOP) are not allowed."

As long as your records has unique key(s), using hash table will give you a huge performance gain when dealing with large dataset. assuming in your case, 10000 record , and if the key is unique, use hash table. The main use of hash tables is for looking up fixed information from a key. So if you have a report that has personnel number and you want to display their name, you could use a hash table.

Thus:

Code:

types: begin of typ_pernr,

pernr like pa0001-pernr,

ename like pa0001-ename,

end of typ_pernr.

data: ls_pernr type typ_pernr,

lt_pernr type hashed table of typ_pernr with unique key pernr.

...

select pernr ename into table lt_pernr from pa0001.

...

loop at itab.

read table lt_pernr with table key pernr = itab-pernr

into ls_pernr.

write: ls_pernr-ename, itab-data.

endloop.

Kindly Reward Points If You Found The Reply Helpful,

Cheers,

Chaitanya.