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

hashed table

Former Member
0 Likes
703

i m not able to create a internal name for an hashed table.

i m getting the following error.

"%_HASHED_TABLE" is a generic type. A type reference is possible only for field symbols and formal parameters

how to create an internal table like an hashed table.....

thans in advance

4 REPLIES 4
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
645

first create a structure as follows:

data:begin of it_struct,

mblnr like mseg-mblnr,

matnr like mseg-matnr,

end of it_struct.

data: itab1 like hashed table of it_struct with unique key mblnr with header line.

Note use insert to add records to the hashed itab.

while using read statement on it specify the unique key...

reward if usefull

Read only

Former Member
0 Likes
645

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

The table object ITAB has the type hashed table, a line type corresponding to the flat structure SPFLI from the ABAP Dictionary, and a

unique key with the key fields CARRID and CONNID. The internal table ITAB can be regarded as an internal template for the database table

SPFLI. It is therefore particularly suitable for working with data from this database table as long as you only access it using the key.

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb35de358411d1829f0000e829fbfe/frameset.htm

Regards,

Priyanka.

Read only

Former Member
0 Likes
645

i m having a generic hashed table.

now i want to create a work area. is there any way to access tht table without field symbols..

Thanks

Read only

0 Likes
645

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.

regards,

srinivas

<b>*reward for useful answers*</b>