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

Difference between tables type.

Former Member
0 Likes
1,008

Dear experts,

What is the difference between standard table and hashed table. Please provide the example on how to / in what circumstances we should use standard table and when we should use hashed table.

Thanks to those who can give the answers.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
948

Hi,

Difference between tables type.

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.

Example:

DATA: I_TAB LIKE STANDARD TABLE OF KNA1 WITH NON-UNIQUE KEY NAME1 WITH HEADER LINE INITIAL SIZE 1.

SELECT * FROM KNA1 INTO TABLE I_TAB.

SORT ITAB.

LOOP AT ITAB.

WRITE:/ I_TAB-KUNNR,I_TAB-NAME1,I_TAB-ORT01.

ENDLOOP.

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

ANY TABLE

1.Index Tables

a.Standard Table

b.Sorted Table

2. Hashed Table

Regards,

Jagadish

9 REPLIES 9
Read only

Former Member
0 Likes
949

Hi,

Difference between tables type.

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.

Example:

DATA: I_TAB LIKE STANDARD TABLE OF KNA1 WITH NON-UNIQUE KEY NAME1 WITH HEADER LINE INITIAL SIZE 1.

SELECT * FROM KNA1 INTO TABLE I_TAB.

SORT ITAB.

LOOP AT ITAB.

WRITE:/ I_TAB-KUNNR,I_TAB-NAME1,I_TAB-ORT01.

ENDLOOP.

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

ANY TABLE

1.Index Tables

a.Standard Table

b.Sorted Table

2. Hashed Table

Regards,

Jagadish

Read only

Former Member
0 Likes
948

Hi,

STANDARD INTERNAL TABLE:

For this table data can be resorted for any no.of times. Searching technique is linear search.

DATA: ITAB LIKE STANDARD TABLE OF KNA1 WITH NON-UNIQUE KEY NAME1 WITH HEADER LINE INITIAL SIZE 1.

SELECT * FROM KNA1 INTO TABLE ITAB.

SORT ITAB.

LOOP AT ITAB.

WRITE:/ ITAB-KUNNR,ITAB-NAME1,ITAB-ORT01.

ENDLOOP.

HASHED INTERNAL TABLE:

Default searching is linear. Random oreder reading is not possible. It is more efficient(display) than i=indexed internal tables.

When ever hashed internal tables are defined, table is defined with only two fields. First field is u2018field nameu2019 and second field is u2018field valueu2019. A row in this internal table reprents one field of table. Internal table indexing can be created only for rows which represents one entry. For this tables indexing not generated, internally called as non-index internal table.

Regards,

Chandu

Read only

Former Member
0 Likes
948

Hi Wong,

Difference between table types

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.

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.

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.

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.

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.

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.

Plz rewards points if helpful,

Ganesh.

Read only

Former Member
0 Likes
948

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.

Reward points..

Read only

Former Member
0 Likes
948

Hi

Difference between tables type.

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.

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.

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.

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

Reward If Helpfull,

Naresh.

Read only

Former Member
0 Likes
948

Could you please elaborate more in examples? like example in program...

Read only

0 Likes
948

Hi,

Go to the t-code ABAPDOCU In that Go to

Bc-ABAP Programming -> ABAP Programming Language-->Processing large data sets

In that u will find the internal tables

U can see all the examples on the internal tables so that u can get good idea

on all the table types.

Regards,

Jagadish.

Read only

Former Member
0 Likes
948

hi,

Standard tables have an internal linear index. From a particular size upwards, the indexes of internal tables are administered as trees. In this case, the index administration overhead

increases in logarithmic and not linear relation to the number of lines. The system can access records either by using the table index or the key. The response time for key access

proportional to the number of entries in the table. The key of a standard table is always nonunique. You cannot specify a unique key. This means that standard tables can always be filled very quickly, since the system does not have to check whether there are already existing entries.

This is the most appropriate type if you are going to address the individual table entries using theindex. Index access is the quickest possible access. You should fill a standard table by appending lines (ABAP APPEND statement), and read, modify and delete entries by specifying the index (INDEX option with the relevant ABAP command). The access time for a standard tableincreases 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. Forexample, you could fill the table by appending entries, and then sort it. If you use the binarysearch option with key access, the response time is logarithmically proportional to the number of table entries.

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 remainsconstant, regardless of the number of table entries. Like database tables, hashed tables alwayshave a unique key. Hashed tables are useful if you want to construct and use an internal tablewhich resembles a database table or for processing large amounts of data.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 systemaccess 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.

Edited by: Rajyalakshmi Attili on May 23, 2008 10:04 AM

Read only

Former Member
0 Likes
948

hi there...

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.

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

do reward if helpful or get back with further queries.