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: 

types of internal tables

Former Member
0 Kudos
200

how many types of internaltables ? what r they ? explain them?

standard , sorted , hashed differences

4 REPLIES 4

former_member223537
Active Contributor
0 Kudos
138

1. STANDARD TABLE

2. SORTED TABLE

3. HASHED TABLE

4. INDEX TABLE

5. ANY TABLE

<b>STANDARD TABLE</b>

Effect

Defines the table as a standard table. Key access to a standard table uses a linear search. This means that the timne required for a search is in linear relation to the number of table entries.

You should use index operations to access standard tables.

For the sake of compatibility, you can use TABLE as a synonym of STANDARD TABLE.

<b>Alternative 2

SORTED TABLE</b>

Effect

Defines the table as one that is always saved correctly sorted. Key access to a sorted table uses a binary key. If the key is not unique, the system takes the entry with the lowest index. The runtime required for key access is logarithmically related to the number of table entries.

You can also access sorted tables by index operations. When you insert using an index, the system checks to ensure that the sort sequence has been correctly maintained. For this reason, it takes longer than inserting entries in a standard table. As a rule, you should only access sorted tables using their key.

<b>Alternative 3

HASHED TABLE</b>

Effect

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 oe INSERT itab within a LOOP) are not allowed.

<b>Alternative 4

INDEX TABLE</b>

Effect

Standard and sorted tables belong to the generic class index tables. An index table is one that you can access using an index. You can currently only use the table type INDEX TABLE to specify the type of generic parameters in a FORM or a FUNCTION. Hashed tables are not index tables, and cannot therefore be passed to parameters defined as INDEX TABLE.

<b>Alternative 5</b>

ANY TABLE

Effect

Like INDEX TABLE, you use ANY TABLE to specify the type of any generic table parameter. The set of permitted operations for a table with type ANY TABLE consists of the intersection of all permitted operations for STANDARD, SORTED and HASHED TABLEs, and so is identical to the set of operations permitted for hashed tables.

Note in particular that you cannot use index access for tables with this type.

Former Member
0 Kudos
138

Table type

The table type determines how ABAP will access individual table entries. Internal tables can be divided into three types:

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 is proportional to the number of entries in the table. The key of a standard table is always non-unique. 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.

Sorted tables are always saved sorted by the key. They also have an internal index. The system can access records either by using the table index or the key. The response time for key access is logarithmically proportional 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. When you define the table, you must specify whether the key is to be unique or not. Standard tables and sorted tables are known generically as index tables.

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.

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 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 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 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 INSERT statement. 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 WHERE condition.

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.

paruchuri_nagesh
Active Contributor
0 Kudos
138

hi

We can divide internal table types into three kinds by their access type:

n Standard tables. In a standard table, you can access data using either the table index or the key.

Since the key of a standard table always has to be non-unique for compatibility reasons, the system

searches the whole table each time you access it using the key. Consequently, you should always use

the index to access a standard table whenever possible.

n Sorted tables. In a sorted table, the system automatically stores the entries and inserts new entries

sorted by the table key. The system uses a binary search on the table when you access it using the

key. You can specify the key of a sorted table as unique. You will often use the key to access a

sorted table, but it is also possible to use the index. Standard tables and sorted tables are generically

known as index tables.

n Hashed tables. You can only access a hashed table using the key. There are certain conditions

under which you can considerably reduce the access times t

reward if u find useful

regards

Nagesh.Paruchuri

Former Member
0 Kudos
138

hi,

internal tables are generally of two types only.

1. INTERNAL TABLES WITH HEADER LINE

2. INTERNAL TABLES WITH OUT HEADER LINE

for internal tables with out header line u need to explicitly create a work area and do record processing from it. where as for internal tables with header line a header is created for u while creating an internal table.

n one of dictionary objects are internal table types

1. standard

2. sorted

3. hashed

1. standard: tables which u use frequently.

follows index and allows data with out any condition

for most situations

2.sorted: while entering data only data is sorted

follows index and keys are used as index.

retreiving data from this table is faster than standard tables

3.hashed tables: uses a hashed algorithm for logic

no index n keys used

fatser than remaining two tables for accessing data

if helpful reward some points.

with regards,

Suresh Aluri.