‎2008 Dec 30 9:43 AM
Hi,
Can you please guide me regarding hashed and sorted table. what should be the ideal record size for sorted / hashed tables and in below code how i can used sorted / hashed table in place of standard table.
Please advise.
TYPES : BEGIN OF st_crmd_link,
guid_hi LIKE crmd_link-guid_hi,
guid_set LIKE crmd_link-guid_set,
objtype_hi LIKE crmd_link-objtype_hi,
objtype_set LIKE crmd_link-objtype_set,
END OF st_crmd_link.
DATA : it_crmd_link TYPE TABLE OF st_crmd_link,
wa_crmd_link LIKE LINE OF it_crmd_link.
SELECT guid_hi
guid_set
objtype_hi
objtype_set
FROM crmd_link
INTO CORRESPONDING FIELDS OF TABLE it_crmd_link
FOR ALL ENTRIES IN it_final.
loop into it_crmd_link into wa_crmd_link.
endloop.
Regards,
Santosh
‎2008 Dec 30 10:08 AM
Hi,
Please go through this link will help you.
http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb35de358411d1829f0000e829fbfe/content.htm
‎2008 Dec 30 10:08 AM
Hi,
Please go through this link will help you.
http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb35de358411d1829f0000e829fbfe/content.htm
‎2008 Dec 30 10:31 AM
Hi ,
U can choose teh specific table type depending on your requirement.
Standard Internal Tables
Standard tables have a linear index. You can access them using either the index or the key. If you use the key, the response time is in linear relationship to the number of table entries. The key of a standard table is always non-unique, and you may not include any specification for the uniqueness in the table definition.
This table type is particularly appropriate if you want to address individual table entries using the index. This is the quickest way to access table entries. To fill a standard table, append lines using the (APPEND) statement. You should read, modify and delete lines by referring to the index (INDEX option with the relevant ABAP command). The response time for accessing a standard table is in linear relation to the number of table entries. If you need to use key access, standard tables are appropriate if you can fill and process the table in separate steps. For example, you can fill a standard table by appending records and then sort it. If you then use key access with the binary search option (BINARY), the response time is in logarithmic relation to
the number of table entries.
Sorted Internal Tables
Sorted tables are always saved correctly sorted by key. They also have a linear key, and, like standard tables, you can access them using either the table index or the key. When you use the key, the response time is in logarithmic relationship to the number of table entries, since the system uses a binary search. The key of a sorted table can be either unique, or non-unique, and you must specify either UNIQUE or NON-UNIQUE in the table definition. Standard tables and sorted tables both belong to the generic group index tables.
This table type is particularly suitable if you want the table to be sorted while you are still adding entries to it. You fill the table using the (INSERT) statement, according to the sort sequence defined in the table key. Table entries that do not fit are recognised before they are inserted. The response time for access using the key is in logarithmic relation to the number of
table entries, since the system automatically uses a binary search. Sorted tables are appropriate for partially sequential processing in a LOOP, as long as the WHERE condition contains the beginning of the table key.
Hashed Internal Tables
Hashes tables have no internal linear index. You can only access hashed tables by specifying the key. The response time is constant, regardless of the number of table entries, since the search uses a hash algorithm. The key of a hashed table must be unique, and you must specify UNIQUE in the table definition.
This table type is particularly suitable if you want mainly to use key access for table entries. You cannot access hashed tables using the index. When you use key access, the response time remains constant, regardless of the number of table entries. As with database tables, the key of a hashed table is always unique. Hashed tables are therefore a useful way of constructing and
using internal tables that are similar to database tables.
Regards,
Radhika.
‎2008 Dec 30 10:36 AM
Hi Santhosh,
Hashed table:
Only Key access possible, no index access
unique Key is required
Hashed table shud be used if the internal table is too large.
Sorted Table:
Both Index and key acess possible
Unique/Non unique Key
Append is possible only with Standard tables, so it cannot be performed on hashed and sorted table.
Insert is possible in all the three tables but has different effects in all three
in sorted table : it is inserted at the right place depending on the key.
in Hased Table : Inserted according to Hash algorithm.
‎2008 Dec 30 10:53 AM
Hashed Table:
Hashed table is useful when you have to work with very big internal table. The time access is constant!
. 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.
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 have 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.
types: begin of typ_pernr,
pernr like pa0001-pernr,
ename like pa0001-ename,
end of typ_pernr.
data: lt_pernr type hashed table of typ_pernr with unique key pernr.
Sorted Table:
Sorted tables are always saved correctly sorted by key. When you use the key, the response time is in logarithmic relationship to the number of table entries, since the system uses a binary search. The key of a sorted table can be either unique, or non-unique, and you must specify either UNIQUE or NON-UNIQUE in the table definition. Standard tables and sorted tables both belong to the generic group index tables.
Data: lt_pernr type sorted table of typ_pernr with non-unique key pernr.