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

Read table binary search

Former Member
0 Likes
1,494

Hi all,

Can i use raed table binary search for Hased tables? I coded like this

DATA:T_MODEL_HASH LIKE HASHED TABLE OF T_MODEL

WITH UNIQUE KEY PBPINO WITH HEADER LINE.

READ TABLE t_model_hash WITH KEY pbpino = t_zwpbph-pbpapino

BINARY SEARCH.

But iam getting syntax error "cannot use explicit or implicit index operations on hased tables ".can any one let me know about this issue?

1 ACCEPTED SOLUTION
Read only

ferry_lianto
Active Contributor
0 Likes
1,052

Hi Priya,

Hashed tables are managed by a hash algorithm. There is no logical index. The entries are not ordered in the memory. The position of a row is calculated by specifying a key using a hash function.

A hashed table's performance in reads is NOT dependent on the number of records. However, it is intended for reads that will return only and only one record. It uses a "side-table" with a hash algorithm to store off the physical location of the record in the actual internal table. It is not NECESSARILY sorted/organized in an meaningful order (like a sorted table is). Please note that changes to a hashed tables records must be managed carefully.

Please check this link to understand how to use hash table.

http://help.sap.com/saphelp_erp2004/helpdata/en/fc/eb362c358411d1829f0000e829fbfe/frameset.htm

Regards,

Ferry Lianto

5 REPLIES 5
Read only

Former Member
0 Likes
1,052

Yes u r right...You cannot use BINARY SEARCH for HASHED tables and SORTED tables, only used with STANDARD TABLES

there is implicit binay search for Hashed table

chk below help

STANDARD TABLE:

If you use the ... BINARY SEARCH addition, the system uses a binary search. Otherwise, the search is sequential. This assumes that the internal table is sorted in ascending order in the sequence of the specified key fields.

SORTED TABLE:

If the specified key fields form a left-justified extract of the table key or are identical with the entire table key, the search is binary, otherwise sequential.

HASHED TABLE:

If the key fields specified are identical with the entire table key, the hash algorithm is used, otherwise read access is sequential.

Read only

Former Member
0 Likes
1,052

Hi Priya,

When use Hashed tables, For each record there will be a Hash Key.

The access to a table (eg: read,update,modify,insert) will be done based on this Hash Key.

Hash key are generated by Hash algorithms.

So, you no need to use BINARY SEARCH clause for Hashed table using READ statement.

Thanks,

Vinay

Read only

Former Member
0 Likes
1,052

For hashed tables, the hash algorithm is used if the specified search key includes the table key. Otherwise the search is linear. The addition BINARY SEARCH is not permitted for hashed tables.

Read only

ferry_lianto
Active Contributor
0 Likes
1,053

Hi Priya,

Hashed tables are managed by a hash algorithm. There is no logical index. The entries are not ordered in the memory. The position of a row is calculated by specifying a key using a hash function.

A hashed table's performance in reads is NOT dependent on the number of records. However, it is intended for reads that will return only and only one record. It uses a "side-table" with a hash algorithm to store off the physical location of the record in the actual internal table. It is not NECESSARILY sorted/organized in an meaningful order (like a sorted table is). Please note that changes to a hashed tables records must be managed carefully.

Please check this link to understand how to use hash table.

http://help.sap.com/saphelp_erp2004/helpdata/en/fc/eb362c358411d1829f0000e829fbfe/frameset.htm

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
1,052

When you have declared it as Hashed table why use BINARY SEARCH???

Hash functions are much faster than binary search techniques.

You have to change the syntax in this way

READ TABLE t_model_hash WITH <b>TABLE</b> KEY pbpino = t_zwpbph-pbpapino.