Internal tables in ABAP

There are 3 types of internal tables in the ABAP

1)Standard internal table
2)Sorted internal table
3)Hashed internal table

Standard internal table:
  • Key of the table is always non unique and duplicate records are allowed
  • We can access the table by using the Key or Index
  • Response time is in logarithmic relationship to the number of table entries, since the system uses a linear search.
  • For filling the internal table we need to use the APPEND statement.


Standard table declaration:

TYPES:BEGIN OF ty_data,
              kunnr type kunnr,
              name1 type name1,
              END OF ty_data.


DATA:it_standard type standard table of  ty_data.

Sorted internal table:
  • Sorted tables are always sorted by key.
  • Duplicate records are allowed if we use the Non unique key
  • Like standard tables, we can access them using either the table index or the key.
  • When we use the key, the response time is in logarithmic relationship to the number of table entries, since the system uses a binary search.
  • For filling the internal table we need to use the INSERT statement. 

Sorted table declaration:

Sorted table can be declared with unique key or non unique key.
  • If we declare with the unique keys internal table does not have the duplicate records with that particular key
  • If we declare with the non unique keys internal table have the duplicate records
TYPES:BEGIN OF ty_data,
kunnr type kunnr,
name1 type name1,
END OF ty_data.

With unique key:
DATA:it_standard type sorted table of ty_data WITH NON-UNIQUE KEY KUNNR NAME1.

With Non Unique Key:
DATA:it_standard type sorted  table of ty_data  WITH NON-UNIQUE KEY KUNNR NAME1.

Hashed internal table declaration:
  • Like database table this internal table have only unique key
  • The response (Search) time doesn’t depend on the number of records, instead it always remain constant regardless the number of table entries.
  •  It uses the hashed algorithm
Hashed table can be declared with only unique key .
  • If we declare with the unique keys internal table does not have the duplicate records with that particular key
TYPES:BEGIN OF ty_data,
kunnr type kunnr,
name1 type name1,
END OF ty_data.

DATA:it_standard type hashed  table of ty_data WITH UNIQUE KEY KUNNR.

3 comments:

  1. With unique key:
    DATA:it_standard type sorted table of ty_data WITH NON-UNIQUE KEY KUNNR NAME1.

    With Non Unique Key:
    DATA:it_standard type sorted table of ty_data WITH NON-UNIQUE KEY KUNNR NAME1.



    both are same ?

    ReplyDelete
  2. I suppose its a typing mistake. First one should be--- WITH UNIQUE KEY ----

    ReplyDelete
  3. How the data will be filled in Hashed Table ?

    ReplyDelete