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 table

Former Member
0 Likes
25,538

1. what is hash table? where we are using hash tables?

2. how we are calling secondary lists in interactive reports?

useing at user-command... is it right...

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
9,726

Hi,

Basically, there are three types of internal table:

1). Standard ITAB.

2). Hashed ITAB.

3). Sorted ITAB.

Standard Table:

We can access records either using the table index or the key. If we use the key the response time is in linear relation to the number of table entries. The key of a standard table is always NON-UNIQUE. Standard tables are generically index tables.

Sorted table:

The entries are always saved and sorted according to the key. We can access records either using the table index or the key. If we use the key, the response time is in logarithmic relation to the number of table entries since the system uses binary search. The key of a standard table can be either UNIQUE or NON-UNIQUE. Sorted tables are generically index tables.

Hashed table:

We can access hashed tables using their key only. The response time is constant and does not depend on the number of the entries since the system uses a hash algorithm. The key of a standard table must always be UNIQUE.

Please reward points, if its useful.

Regards,

Abhsiehk

7 REPLIES 7
Read only

Former Member
0 Likes
9,726

Hi,

Hashed tables - This is the most appropriate type for any table where the main operation is key access. You cannot access a hashed table using its index. The response time for key access remains constant, regardless of the number of table entries. Like database tables, hashed tables always have a unique key.

use of using HASHED TABLE

Hashed table is useful when your have to work with very big internal table and to read it with

"READ TABLE WITH KEY ..."

The time access is constant !

Definition of a Hashed Table:

"Defines the table as one that is managed with an internal hash procedure. 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.

Access time using the key is constant, regardless of the number of table entries.

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 has 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.

Thus:

Code:

types: begin of typ_pernr,

pernr like pa0001-pernr,

ename like pa0001-ename,

end of typ_pernr.

data: ls_pernr type typ_pernr,

lt_pernr type hashed table of typ_pernr with unique key pernr.

...

select pernr ename into table lt_pernr from pa0001.

...

loop at itab.

read table lt_pernr with table key pernr = itab-pernr

into ls_pernr.

write: ls_pernr-ename, itab-data.

endloop.

2) by using At line slection event you can call secondary lists in interactive report.

at line selection----if we double click on the line then we get the secondary list by using this event.

at user command---by clicking on the function code then we get secondary list by using this event.

regards,

vineela

Read only

Former Member
0 Likes
9,726

Hi,

Hashed table is useful when your have to work with very big internal table and to read it with

"READ TABLE WITH KEY ..."

The time access is constant !

Definition of a Hashed Table:

"Defines the table as one that is managed with an internal hash procedure. 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.

Access time using the key is constant, regardless of the number of table entries.

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 has 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.

Thus:

Code:

types: begin of typ_pernr,

pernr like pa0001-pernr,

ename like pa0001-ename,

end of typ_pernr.

data: ls_pernr type typ_pernr,

lt_pernr type hashed table of typ_pernr with unique key pernr.

...

select pernr ename into table lt_pernr from pa0001.

...

loop at itab.

read table lt_pernr with table key pernr = itab-pernr

into ls_pernr.

write: ls_pernr-ename, itab-data.

endloop.

For interactive report you can use at line selection event for calling the secondary list.

Hope this will help

Regards

Shibin

Read only

Former Member
0 Likes
9,727

Hi,

Basically, there are three types of internal table:

1). Standard ITAB.

2). Hashed ITAB.

3). Sorted ITAB.

Standard Table:

We can access records either using the table index or the key. If we use the key the response time is in linear relation to the number of table entries. The key of a standard table is always NON-UNIQUE. Standard tables are generically index tables.

Sorted table:

The entries are always saved and sorted according to the key. We can access records either using the table index or the key. If we use the key, the response time is in logarithmic relation to the number of table entries since the system uses binary search. The key of a standard table can be either UNIQUE or NON-UNIQUE. Sorted tables are generically index tables.

Hashed table:

We can access hashed tables using their key only. The response time is constant and does not depend on the number of the entries since the system uses a hash algorithm. The key of a standard table must always be UNIQUE.

Please reward points, if its useful.

Regards,

Abhsiehk

Read only

Former Member
0 Likes
9,726

Hi

Hashed tables have no linear index. You can only access a hashed table using its key. The response time is independent of the number of

table entries, and is constant, since the system access the table entries using a hash algorithm. The key of a hashed table must be unique.

When you define the table, you must specify the key as UNIQUE.

This is the most appropriate type for any table where the main operation is key access. You cannot access a hashed table using its index.

The response time for key access remains constant, regardless of the number of table entries. Like database tables, hashed tables always

have a unique key. Hashed tables are useful if you want to construct and use an internal table which resembles a database table or for

processing large amounts of data.

For creating hashed tables.

Fully-specified table types determine how the system will access the entries in the table in key operations. It uses a linear search for

standard tables, a binary search for sorted tables, and a search using a hash algorithm for hashed tables.

Line type

For the line type <linetype>, you can specify:

Any data type if you are using the TYPE addition. This can be a predefined ABAP type, a local type in the program, or a data type from the

ABAP Dictionary. If you specify any of the generic elementary types C, N, P, or X, any attributes that you fail to specify (field length, number

of decimal places) are automatically filled with the default values. You cannot specify any other generic types.

Any data object recognized within the program at that point if you are using the LIKE addition. The line type adopts the fully-specified data

type of the data object to which you refer. Except for within classes, you can still use the LIKE addition to refer to database tables and

structures in the ABAP Dictionary (for compatibility reasons).

All of the lines in the internal table have the fully-specified technical attributes of the specified data type.

Read only

Former Member
0 Likes
9,726

Hi

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.

-


yes,by using at-user command u can secondary lists in interactive reports

Read only

Former Member
0 Likes
9,726

Hi,

Standard table:

The key access to a standard table uses a sequential search. The time required for an access is linearly dependent on the number of entries in the internal table.

You should usually access a standard table with index operations.

Sorted table:

The table is always stored internally sorted by its key. Key access to a sorted table can therefore use a binary search. If the key is not unique, the entry with the lowest index is accessed. The time required for an access is logarithmically dependent on the number of entries in the internal table.

Index accesses to sorted tables are also allowed. You should usually access a sorted table using its key.

Hash table:

The table is internally managed with a hash procedure. All the entries must have a unique key. The time required for a key access is constant, that is it does not depend on the number of entries in the internal table.

You cannot access a hash table with an index. Accesses must use generic key operations (SORT, LOOP, etc.).

Hashed tables

This is the most appropriate type for any table where the main operation is key access. You cannot access a hashed table using its index.

The response time for key access remains constant, regardless of the number of table entries. Like database tables, hashed tables always

have a unique key. Hashed tables are useful if you want to construct and use an internal table which resembles a database table or for

processing large amounts of data.

TYPES VECTOR TYPE HASHED TABLE OF I WITH UNIQUE KEY TABLE LINE.

TYPES: BEGIN OF LINE,

COLUMN1 TYPE I,

COLUMN2 TYPE I,

COLUMN3 TYPE I,

END OF LINE.

DATA ITAB TYPE HASHED TABLE OF SPFLI

WITH UNIQUE KEY CARRID CONNID.

cheers,

vasavi.

Read only

Former Member
0 Likes
9,726

HI Thulasa Naik,

What is use of using HASHED TABLE?

Hashed table is useful when your have to work with very big internal table and to read it with

"READ TABLE WITH KEY ..."

The time access is constant !

Definition of a Hashed Table:

"Defines the table as one that is managed with an internal hash procedure. 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.

Access time using the key is constant, regardless of the number of table entries.

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 has 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.

Thus:

Code:

types: begin of typ_pernr,

pernr like pa0001-pernr,

ename like pa0001-ename,

end of typ_pernr.

data: ls_pernr type typ_pernr,

lt_pernr type hashed table of typ_pernr with unique key pernr.

...

select pernr ename into table lt_pernr from pa0001.

...

loop at itab.

read table lt_pernr with table key pernr = itab-pernr

into ls_pernr.

write: ls_pernr-ename, itab-data.

endloop.

Refer this links for more information,,

http://www.sap-img.com/abap/what-is-use-of-using-hashed-table.htm

http://www.technicalinterview.info/what-is-the-major-advantage-of-a-hash-table/

2 . You are right u can call secondary lists using

" at userCommand " .

EXample:

FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

Please Reward Points If helpful,

Thanks & Regards ,

Sreekar.Kadiri