Application Development 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: 

standard itab

Former Member
0 Kudos
131

hi SAP Technical Guru,

PLS suggest me every time while creating itab we are using stadard internal table only, why not sorted and hashed.

regards,

7 REPLIES 7

Former Member
0 Kudos
112

Hi,

You can got for Sorted and Hashed internal table .

Basically depending on your requirement you define internal table type.

1.Standard Internal Tables: These tables have a linear index and can be accessed using the index or the key. The response time is in linear relationship with number of table entries. These tables are useful when user wants to address individual table entries using the index.

2.Sorted Internal Tables: These tables also have an index and the key. But, the response time is in logarithmic relationship with number of table entries, since it uses binary search algorithm instead of linear search. These tables are useful when user wants the table to be sorted while additional entries have to be added.

3.Hashed Internal Tables: These tables have no index, but have the key. The response time is constant irrespective of number of table entries, since it uses a Hash algorithm. These tables are useful when user wants to access the entries with key only.

Regards,

Sujit

Former Member
0 Kudos
112

>

> hi SAP Technical Guru,

> PLS suggest me every time while creating itab we are using stadard internal table only, why not sorted and hashed.

>

>

> regards,

hi ashwini,

its not like that, it depends upon the requirement we can standard,sorted and hash table also.

1.Standard Internal Tables: These tables have a linear index and can be accessed using the index or the key. The response time is in linear relationship with number of table entries. These tables are useful when user wants to address individual table entries using the index.

2.Sorted Internal Tables: These tables also have an index and the key. But, the response time is in logarithmic relationship with number of table entries, since it uses binary search algorithm instead of linear search. These tables are useful when user wants the table to be sorted while additional entries have to be added.

3.Hashed Internal Tables: These tables have no index, but have the key. The response time is constant irrespective of number of table entries, since it uses a Hash algorithm. These tables are useful when user wants to access the entries with key only.

Edited by: mohammed abdul hai on Jul 24, 2008 1:56 PM

Former Member
0 Kudos
112

hi check this ....

see there are basically two types of tables

index and non-index

under index we have standard tables and sorted tables and under non-index we have hashed table.

depending the requirement we need to use this...but all of them will support append and insert statements. the sorted table is defaultly sorted .

0 Kudos
112

thans venkat ,

would you suggest me the simple requirement to use sorted and hashed.

regards,

0 Kudos
112

Hi

as also said by others it always depend on the requirement what table you use.

refer to the link for use of hash table;

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

http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb35de358411d1829f0000e829fbfe/content.htm

With luck,

Pritam.

0 Kudos
112

hi check this....

we use the sorted tables in the alvs mostly for the interactive reports in many screens or while using the containers....

The sort table is an internal table of type LVC_T_SORT .

You use the sort table to get the current sort criteria of the list or set these criteria dynamically or before the list is displayed for the first time in the alv .

If you use the table in combination with method get_subtotals, you can determine the subtotals values.

Former Member
0 Kudos
112

Hi ashwini,

The use of the internal table depends on the requirement,

u would better understand when u enrich urself on the types of tables go through the below discussion on tables,

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.

CHOOSING A TABLE TYPE

The table type (and particularly the access method) that you will use depends on how the typical internal table operations will be most frequently executed.

Standard tables

This is the most appropriate type if you are going to address the individual table entries using the index. Index access is the quickest possible access. You should fill a standard table by appending lines (ABAP APPENDstatement), and read, modify and delete entries by specifying the index (INDEX option with the relevant ABAP command). The access time for a standard table increases in a linear relationship with the number of table entries. If you need key access, standard tables are particularly useful if you can fill and process the table in separate steps. For example, you could fill the table by appending entries, and then sort it. If you use the binary search option (BINARY) with key access, the response time is logarithmically proportional to the number of table entries.

Sorted tables

This is the most appropriate type if you need a table which is sorted as you fill it. You fill sorted tables using the INSERTstatement. Entries are inserted according to the sort sequence defined through the table key. Any illegal entries are recognized as soon as you try to add them to the table. The response time for key access is logarithmically proportional to the number of table entries, since the system always uses a binary search. Sorted tables are particularly useful for partially sequential processing in a LOOP if you specify the beginning of the table key in the WHEREcondition.

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.

With thanks & regards,

Sravani yendru.