Application Development 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: 

Do I need to sort a hashed table before reading ?

Former Member
0 Kudos

1) I populate a hashed internal table :

data :

i_droplist type hashed table of t_droplist

with unique key gpart vkont,

select gpart

vkont

into table i_droplist

from zxis_0x_dun_drop

for all entries in i_jointab1

where gpart = i_jointab1-gpart

and vkont = i_jointab1-vkont.

2) read table i_droplist transporting no fields

with table key gpart = p_gpart

vkont = p_vkont.

Before reading the table is it needed to sort the hashed table on the key ?

I think it is not necessary but I am not sure ...

Thanks for your help,

Marie

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Marie,

It is not Mandatory to use Sort before Read for a hashed table.

Regards,

Santosh

Reward if it helps...

6 REPLIES 6

Former Member
0 Kudos

Hi Marie,

It is not Mandatory to use Sort before Read for a hashed table.

Regards,

Santosh

Reward if it helps...

Former Member
0 Kudos

Hi

No! You can't do it because the system sorts the records while loading them.

Max

Former Member
0 Kudos

Hi,

no need.

When you write to the hashed table it uses a hashing algorithm to identify where the record is stored (think if this as writing the location of a page in an index of a book). When you READ this table the system looks up this "index" and retrieves the record. Because of this the retrieval time is constant.

rgds,

latheesh

Message was edited by: Latheesh Kaduthara

former_member181962
Active Contributor
0 Kudos

There is no need to sort it.

Regards,

ravi

0 Kudos

DO NOT SORT IT !!!!

A hashed table is not sorted in any way. It is organized according to a "hash" algorithm, which is a mathematical calculation.

This "hashing" provides for maximize speed of data retrival when looking for a SINGLE, UNIQUE record!!

If you have multiple records in the internal table with the same key, a hash table is NOT the way to go. In that case, use a SORTED table.

But DO NOT sort a hashed table... you will probably find performance degradation AFTER a SORT is performed on one. SAP will "realize" that the hash algorithm has been borken... and SAP will start to read the int table sequentially.

abdul_hakim
Active Contributor
0 Kudos

<b>Not needed!!</b>

Cheers,

Abdul Hakim

Mark all useful answers..