Quick Contact

    SAP Tutorial

    Internal Tables and Work areas

    Internal Tables and Work Areas are temporary memory locations which are used to store the data of database tables at run time and in other way we can call them as instances of database tables.

    Internal tables and Work areas
    Internal Tables Work Areas
    Temporary memory locations which are used to store the data of database table.

    Internal table is an instance of database table.

    By default 8kb memory will be allocated and it increases dynamically( +8kb +8kb).

    Temporary memory locations which are used to store the data of database table.

    Work area is an instance of database table.

    Internal tables can store multiple records. Work areas can store only one record.
    General Syntax :

    DATA :< ITAB> TYPE TABLE OF < DBTABLE> .

    General Syntax:

    DATA :< WA> TYPE < DBTABLE> .

    Internal Table declaration

    DATA :< ITAB> TYPE TABLE OF < DBTABLE> .

    Example :

    DATA : IT_ITAB TYPE TABLE OF MARA .

    Example Explanation : Here IT_ITAB is the name of Internal table and MARA is the Database table name, after declaring, IT_ITAB will be the instance of table MARA.

    An internal Table declaration with user defined types
    DATA :< ITAB> TYPE TABLE OF < userdefinedtype>. 
    Example is : TYPES : BEGIN OF TY_TABLE,
                   MATNR TYPE MARA-MATNR, 
                   MTART TYPE MARA-MTART,
                   MEINS TYPE MARA-MEINS, 
                   END OF TY_TABLE.< br>
    DATA : IT_ITAB TYPE TABLE OF TY_TABLE .
    

    Here TY_TABLE is a user defined type with 3 fields

    Internal Table Deceleration Old Syntax (Obsolete Method)

    Obsolete Syntax: DATA : IT_ITAB TYPE TABLE OF MARA occurs 0 with header line .

    In this example Internal Table itself acts as work area, technically a work area will be created at the first row of the internal table.

    The data type of an internal table is fully specified by its line type, key, and table type. There are three types of internal table. They are – Standard Tables, Sorted Tables, and Hashed Tables.

    The difference between standard tables, sorted table and hashed tables are –
    Standard Table

    -It has an internal linear index.

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

    -You cannot specify a unique key. It has always non-unique key.

    Sorted Table

    – Sorted table 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 NON-UNIQUE.

    Hashed Table

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

    What is Extracts? How it is different from internal table?

    Extracts are dynamic sequential datasets in which different lines can have different structures. Each ABAP program may currently only have a single extract dataset. You cannot access the individual records in an extract using key or index. Instead, you always process them using a loop.

    Copyright 1999- Ducat Creative, All rights reserved.