Skip to Content
author's profile photo Former Member
Former Member

pls tell me typese of internal table with examples

hi experts,

can any one pls tell me types of internal table with examples shown. reward points.

rergads

fareedas

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 24, 2007 at 07:24 AM

    Hi,

    What Are Different Types Of Internal Tables and Their Usage

    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.

    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

    |

    -


    | |

    Index Tables Hashed Table

    |

    -


    | |

    Standard Table Sorted Table

    - Selva

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 24, 2007 at 07:30 AM
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 24, 2007 at 07:31 AM
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 24, 2007 at 09:31 AM

    Hi,

    Internal tables can be divided into three types:

    Standard tables

    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

    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

    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.

    Example of Standard table:

    DATA: BEGIN OF LINE,

    COL1,

    COL2,

    END OF LINE.

    DATA: ETAB LIKE TABLE OF LINE WITH HEADER LINE,

    FTAB LIKE TABLE OF LINE.

    LINE-COL1 = 'A'. LINE-COL2 = 'B'.

    APPEND LINE TO ETAB.

    MOVE ETAB[] TO FTAB.

    LOOP AT FTAB INTO LINE.

    WRITE: / LINE-COL1, LINE-COL2.

    ENDLOOP.

    The output is:

    A B

    The example creates two standard tables ETAB and FTAB with the line type of the structure LINE. ETAB has a header line. After filling ETAB line by line using the APPEND statement, its entire contents are assigned to FTAB. Note the brackets in the statement.

    Example of Sorted table:

    TYPES: BEGIN OF LINE,

    COLUMN1 TYPE I,

    COLUMN2 TYPE I,

    COLUMN3 TYPE I,

    END OF LINE.

    TYPES ITAB TYPE SORTED TABLE OF LINE WITH UNIQUE KEY COLUMN1.

    The program defines a table type ITAB. It is a sorted table, with line type of the structure LINE and a unique key of the component COLUMN1.

    Example of Hashed table:

    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.

    TYPES ITAB TYPE SORTED TABLE OF LINE WITH UNIQUE KEY COLUMN1.

    TYPES: BEGIN OF DEEPLINE,

    FIELD TYPE C,

    TABLE1 TYPE VECTOR,

    TABLE2 TYPE ITAB,

    END OF DEEPLINE.

    TYPES DEEPTABLE TYPE STANDARD TABLE OF DEEPLINE WITH DEFAULT KEY.

    The program defines a table type VECTOR with type hashed table, the elementary line type I and a unique key of the entire table line. The second table type is the same as in the previous example. The structure DEEPLINE contains the internal table as a component. The table type DEEPTABLE has the line type DEEPLINE. Therefore, the elements of this internal table are themselves internal tables. The key is the default key - in this case the column FIELD. The key is non-unique, since the table is a standard table.

    Regards,

    Bhaskar

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 24, 2007 at 09:52 AM

    internal tables can be classified like below theoratical concept.

    Standard tables

    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

    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

    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.

    Example of Standard table: Practical Aspect

    Prac-1

    DATA: BEGIN OF LINE,

    COL1,

    COL2,

    END OF LINE.

    DATA: ETAB LIKE TABLE OF LINE WITH HEADER LINE,

    FTAB LIKE TABLE OF LINE.

    LINE-COL1 = 'A'. LINE-COL2 = 'B'.

    APPEND LINE TO ETAB.

    MOVE ETAB[] TO FTAB.

    LOOP AT FTAB INTO LINE.

    WRITE: / LINE-COL1, LINE-COL2.

    ENDLOOP.

    The output is:

    A B

    The example creates two standard tables ETAB and FTAB with the line type of the structure LINE. ETAB has a header line. After filling ETAB line by line using the APPEND statement, its entire contents are assigned to FTAB. Note the brackets in the statement.

    *Example of Sorted table: Practical Aspect *

    Prac-2

    TYPES: BEGIN OF LINE,

    COLUMN1 TYPE I,

    COLUMN2 TYPE I,

    COLUMN3 TYPE I,

    END OF LINE.

    TYPES ITAB TYPE SORTED TABLE OF LINE WITH UNIQUE KEY COLUMN1.

    The program defines a table type ITAB. It is a sorted table, with line type of the structure LINE and a unique key of the component COLUMN1.

    Example of Hashed table: Practical Aspect

    Prac-3.

    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.

    TYPES ITAB TYPE SORTED TABLE OF LINE WITH UNIQUE KEY COLUMN1.

    TYPES: BEGIN OF DEEPLINE,

    FIELD TYPE C,

    TABLE1 TYPE VECTOR,

    TABLE2 TYPE ITAB,

    END OF DEEPLINE.

    TYPES DEEPTABLE TYPE STANDARD TABLE OF DEEPLINE WITH DEFAULT KEY.

    Regards,

    Rajesh

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 24, 2007 at 07:31 AM

    Hi

    There are 3 types of internal tables.

    internal tables can be classified like below.

    INDEX NON-INDEX

    STANDARD and SORTED HASHED

    Standard and sorted use indeces while hashed will not use index.

    http://www.sap-img.com/abap/what-are-different-types-of-internal-tables-and-their-usage.htm

    declaration:

    TYPES: BEGIN OF TY_STUDENT,

    SNO TYPE I,

    SNAME(5),

    END OF TY_STUDENT.

    DATA: IT_STUDENT TYPE TABLE OF TY_STUDENT (STANDARD TABLE DECL)

    DATA: IT_STUDENT TYPE SORTED TABEL OF TY_STUDENT (SORTED)

    DATA: IT_STUDENT TYPE HASHED TABLE OF TY_STUDENT WITH KEY... (HASHED)

    TYPES - tabkind

    Syntax

    ... { {STANDARD TABLE}

    | {SORTED TABLE}

    | {HASHED TABLE}

    | {ANY TABLE}

    | {INDEX TABLE} } ... .

    Effect

    Definition of the table type in an internal table.

    You can specify the non-generic table types standard table ( STANDARD TABLE), sorted table ( SORTED TABLE), and hashed table (HASHED TABLE), as well as the generic table types ANY TABLE and INDEX TABLE. The addition STANDARD is optional for standard tables.

    The non-generic table types determine the internal administration and access type in the ABAP program for an internal table:

    Standard tables are managed system-internally by a logical index. New rows are either attached to the table or added at certain positions. The table key or the index identify individual rows.

    Sorted tables are managed by a logical index (like standard tables). The entries are listed in ascending order according to table key.

    Hashed tables are managed by a hash algorithm. There is no logical index. The entries are not ordered in the memory. The position of a row is calculated by specifying a key using a hash function.

    The generic table types define a generic table type that can only be used for typing formal parameters and field symbols:

    ANY TABLE includes all table types.

    INDEX TABLE includes all standard tables and sorted tables.

    Regards

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.