10-21-2016 4:13 PM
If we do a select into an internal table which is of type 'hashed table', will the entries be sorted by the key you provided in the definition of the hashed table?
10-21-2016 9:49 PM
But why does it matter? Hashed tables meant to be accessed by key anyway. Also would be very easy to check in debugger, I guess. I would but I fail to see the importance here. 🙂 Maybe I'm missing something...
10-21-2016 4:25 PM
10-24-2016 12:44 PM
No. There is no defined sort order on a HASHED table. Almost by definition.
10-24-2016 3:54 PM
My idea was that it can be sorted with a hash key... Just some misanderstanding from my side!
10-21-2016 5:11 PM
EDIT: Agreed. a hashed table has NO sort order (Initial answer: Yes or No, it dépends from external factors not related to the information you posted. If you insert 2 lines chronologically in the reverse order of the key, and you do a simple LOOP AT without mentioning any key, then it will read chronologically and not based on the key.)
10-21-2016 9:49 PM
But why does it matter? Hashed tables meant to be accessed by key anyway. Also would be very easy to check in debugger, I guess. I would but I fail to see the importance here. 🙂 Maybe I'm missing something...
10-24-2016 12:09 PM
Dear Jelena
At a customer we did a select into a hashed table with one key.
We expected to see all the data in this hashed table in debugger but couldn't find the entry we were looking for because the data was not sorted. That's why I asked this question in order to find out if we made some kind of error.
After some further discussions with colleagues we found out that a hashed table is not sorted.
10-24-2016 12:44 PM
There is no defined sort order on a HASHED table. You can sort a HASHED table and loop through it and get the records in order, but if you don't sort it, you absolutely cannot rely on any sort order.
10-24-2016 2:08 PM
No, hashed tables are not in any sorted order and aside from any specialized implementations they are not addressable by index. Here is the definition directly from the help that describes them in a brief statement.
Regards,
Ryan Crosby
11-02-2016 6:17 PM
Note you can define secondary keys for internal table since Netweaver 7.02+, but you must also specify the key (k1in my example) while accessing the table entries say in a LOOP or a READ TABLE.
DATA itab TYPE HASHED TABLE OF s1 WITH UNIQUE KEY b
WITH UNIQUE SORTED KEY k1 COMPONENTS a c.