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 Algorithm

Former Member
0 Likes
714

Hello All,

I have internal table1 - itab1 type standard internal table.

and internal table2 - itab2 type hashed internal table.

in itab1 and itab2 the common field is fld1 and this is the unique key in itab2.

now i am sorting itab1 by fld1.

then reading itab2 with key fld1.

the system should use hash algorithm to search the records.

but my question is, is there any place in the debugging mode or any tool provided by SAP, where i can see that the system uses really hash technique or sequential search. this is because, if there is mismatch between key of two tables, then the system will make a sequential search.

if any body knows this, please revert back soon.

Regards,

Bhanu

4 REPLIES 4
Read only

Former Member
0 Likes
559

Hi Bhanu,

you might want to fill only the hash table, sort it, and loop over it. ( and not use the standard table ).

If you want to stay with your solution with two tables: in my opinion the access to a hash table always uses a hash algorithm. If there is a mismatch between the two internal tables, the read access to the hash table will result in not finding the record.

regards,

Rolf

Read only

0 Likes
559

Hello Rolf,

I will briefly explain you what I am upto. I have two internal tables.

ITAB1, - hashed table:contains 1500000 records

FIELD1: KUNNR,

FIELD2: ZFIELD(custom field),

END ITAB1.

ITAB2, - standard table: contains 200000 records

FIELD1: KUNNR - KEY FIELD

FIELD2: VKBUR,

FIELD3: ZFIELD(custom field) - the same field in ITAB1

END ITAB2.

Now my code roughly goes like this.

SORT ITAB2 BY KUNNR.

LOOP AT ITAB2 ASSIGNING <FS>.

READ TABLE ITAB1 WITH KEY KUNNR = <FS>-KUNNR ASSIGNING <SS>.

IF SY-SUBRC EQ 0.

<FS>-ZFIELD = <SS>-ZFIELD.

ENDIF.

ENDLOOP.

My question was is there any navigation in debugging mode / any SAP provided tool, where I can see whether the system makes hash technique to read records from ITAB1 or sequential search.

For example when you go to st05, query shows, where the SELECT statement made sequential search, where it made direct read or where it made access using index.

The same way I want to see search technique for a READ statement on an internal table.

Regards,

Bhanu

Read only

Former Member
0 Likes
559

I do not know how to check the algorithm, without debugging.

An alternative is to compare with the binary search method: copy your program, change the hash table to a standard table, sort, and use read statement using binary search. ( or better: use a sorted table ). Then compare the speed to the original progam. For a large number of records you should see a difference..

regards,

Rolf

Read only

Former Member
0 Likes
559

I dont really understand the problem:

a hashed table always uses the hashed algorithm to access a record, there is no other way.

To sort a hashed table is possible, but it does not make much sense in respect of performance, but of course for display purposes.

Your sort of itab2 in front of the loop will also not help, it will only cost.

loop at itab2 in wa2.

read iatb1 with key k1 = wa2-k1

with itab2 standard table

and itab1 hashed table with k1 unique key

is perfectly o.k., there is no further check necessary!

Siegfried