How to create hashed tables?and its purpose
Answers were Sorted based on User's Feedback
Answer / buddula15
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.Hashed table
is useful when your have to work with very big internal
table and to read it with "READ TABLE WITH KEY ..." .
Sample code for Hashed table Creation :
begin of typ_pernr,
pernr like pa0001-pernr,
ename like pa0001-ename,
end of typ_pernr.
ls_pernr type typ_pernr,
lt_pernr type hashed table of typ_pernr with unique key
select pernr ename into table lt_pernr from pa0001.
loop at itab.
read table lt_pernr with table key pernr = itab-pernr
write: ls_pernr-ename, itab-data.
|Is This Answer Correct ?||19 Yes||2 No|
Answer / gary
the Answer1 is current,I just want to add some additional answer:
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.
Index table is only used to specify the type of generic parameters in a FORM or FUNCTION. That means that you can't create a table of type INDEX.
Internal tables are not DB tables. Standard and Sorted tables in combined are basically called as Index tables and there nothing else. Here is the hierarchy
Index Tables Hashed Table
Standard Table Sorted Table
|Is This Answer Correct ?||4 Yes||0 No|
in ECC6.0 version which package u r working means what? if errors occurs during database updation using bapi how vl v know??bcoz it directly updates db?? how vl v pass tables in smartformd?
How can you tell me the already existing RFC destination with logon client,name?
What is the difference between Search help and Match code ?
What are the basic objects of the data dictionary? : abap data dictionary
How to get the column count of a report?
Suppose in the BDC call transaction we updated one record into the database. In the message log it is showing successful, but it was not updated into the data base? How can we handle?
What is the difference between select statement and provide statement ? : abap hr
if take one table with max no of records,in that i transfer only three records to quality r production r anywhere how it is possible?
what is Transport Request? why it is needed for us?
What are logical databases? : abap hr
What is a view in sap? : abap data dictionary
What is singleton pattern in OOPS?