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: 

Internal table

Former Member
0 Kudos

Can anyone explain me what is the difference between Internal table and table type?

9 REPLIES 9

Former Member
0 Kudos

Hi,

Internal table will be created temporarly in memory through abap program.

Table type will be created DB dictionary via SE11. It is permanent .

Former Member
0 Kudos

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.

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

http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb366d358411d1829f0000e829fbfe/content.htm

http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb340d358411d1829f0000e829fbfe/content.htm

TYPES: BEGIN OF mytext,

number TYPE i,

name TYPE c LENGTH 10,

END OF mytext.

TYPES mytab TYPE STANDARD TABLE OF mytext WITH DEFAULT KEY.

A data type mytab is defined as an internal table with the line type mytext.

<b>It is better to declare internal tables using table types</b>

<b>Declaring internal table</b>

http://www.sapdevelopment.co.uk/tips/tips_itab.htm

http://help.sap.com/saphelp_47x200/helpdata/en/fc/eb35de358411d1829f0000e829fbfe/content.htm

anversha_s
Active Contributor
0 Kudos

hi,

1. Internal table is created inside the program to store data temperorly. so every time no need to access the DB. So it is very fast.

2. TABLE TYPE IS NOTHING BUT A DEFINITION OF DB TABLE.

FOR USING IT IN SMARTFORM U HAVE TO DECLARE IT IN DATABASE(IE,CREATE IN se11) .unless u create it u cannot include in the interfac e definition of smartform.

Regards,

Anver

Former Member
0 Kudos

Internal table is the temporary table created in the ABAP.

Table type is used to create the internal table (just like the structure / table ) . Table type gives the functional settings of the internal table.

That is.

A table type describes the structure and functional attributes of an internal table in ABAP. In ABAP programs you can reference a table type TTYP defined in the ABAP Dictionary with the command DATA <inttab> TYPE TTYP. An internal table <inttab> is created in the program with the attributes defined for TTYP in the ABAP Dictionary.

Please refer the following link for further details.

http://help.sap.com/saphelp_erp2005vp/helpdata/en/90/8d7304b1af11d194f600a0c929b3c3/frameset.htm

Former Member
0 Kudos

Hi,

Table Type :

A table type describes the structure and functional attributes of an internal table in ABAP. In ABAP programs you can reference a table type TTYP defined in the ABAP Dictionary with the command DATA <inttab> TYPE TTYP. An internal table <inttab> is created in the program with the attributes defined for TTYP in the ABAP Dictionary.

A table type is defined by:

its line type, that defines the structure and data type attributes of a line of the internal table

the options for managing and accessing the data ( access mode) in the internal table

the key ( key definition and key category) of the internal table

The row type is defined by directly entering the data type, length and number of decimal places or by referencing a data element, structured type ( structure, table or view) or other table type. Or the row type can be a reference type.

for more info :

http://help.sap.com/saphelp_nw2004s/helpdata/en/90/8d7304b1af11d194f600a0c929b3c3/frameset.htm

Internal Tables :

Internal tables

Internal tables provide a means of taking data from a fixed structure and storing it in working memory in ABAP. The data is stored line by line in memory, and each line has the same structure. In ABAP, internal tables fulfill the function of arrays. Since they are dynamic data objects, they save the programmer the task of dynamic memory management in his or her programs. You should use internal tables whenever you want to process a dataset with a fixed structure within a program. A particularly important use for internal tables is for storing and formatting data from a database table within a program. They are also a good way of including very complicated data structures in an ABAP program.

Like all elements in the ABAP type concept, internal tables can exist both as data types and as data objects A data type is the abstract description of an internal table, either in a program or centrally in the ABAP Dictionary, that you use to create a concrete data object. The data type is also an attribute of an existing data object.

Internal Tables as Data Types

Internal tables and structures are the two structured data types in ABAP. The data type of an internal table is fully specified by its line type, key, and table type.

Line type

The line type of an internal table can be any data type. The data type of an internal table is normally a structure. Each component of the structure is a column in the internal table. However, the line type may also be elementary or another internal table.

Key

The key identifies table rows. There are two kinds of key for internal tables - the standard key and a user-defined key. You can specify whether the key should be UNIQUE or NON-UNIQUE. Internal tables with a unique key cannot contain duplicate entries. The uniqueness depends on the table access method.

If a table has a structured line type, its default key consists of all of its non-numerical columns that are not references or themselves internal tables. If a table has an elementary line type, the default key is the entire line. The default key of an internal table whose line type is an internal table, the default key is empty.

The user-defined key can contain any columns of the internal table that are not references or themselves internal tables. Internal tables with a user-defined key are called key tables. When you define the key, the sequence of the key fields is significant. You should remember this, for example, if you intend to sort the table according to the key.

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.

Generic Internal Tables

Unlike other local data types in programs, you do not have to specify the data type of an internal table fully. Instead, you can specify a generic construction, that is, the key or key and line type of an internal table data type may remain unspecified. You can use generic internal tables to specify the types of field symbols and the interface parameters of procedures . You cannot use them to declare data objects.

Internal Tables as Dynamic Data Objects

Data objects that are defined either with the data type of an internal table, or directly as an internal table, are always fully defined in respect of their line type, key and access method. However, the number of lines is not fixed. Thus internal tables are dynamic data objects, since they can contain any number of lines of a particular type. The only restriction on the number of lines an internal table may contain are the limits of your system installation. The maximum memory that can be occupied by an internal table (including its internal administration) is 2 gigabytes. A more realistic figure is up to 500 megabytes. An additional restriction for hashed tables is that they may not contain more than 2 million entries. The line types of internal tables can be any ABAP data types - elementary, structured, or internal tables. The individual lines of an internal table are called table lines or table entries. Each component of a structured line is called a column in the internal table.

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.

http://help.sap.com/saphelp_47x200/helpdata/en/fc/eb35de358411d1829f0000e829fbfe/content.htm

Regards

Shiva

Former Member
0 Kudos

<u><b>A table type</b></u> describes the structure and functional attributes of an internal table in ABAP.

A table type is defined by its line type, that defines the structure and data type attributes of a line of the internal table .

A table type defined in the ABAP Dictionary or using TYPES or DATA is fully specified by:

<b>Row Type</b> The row type of an internal table can be any data type. If the row type is structured, the individual components of a row are called columns of the internal table.

<b>Table Category</b> The table category defines how an internal table is managed and how the individual rows can be accessed. There are three table categories:

<b>Standard tables</b> are managed internally by a table index which may be realized by means of a logical index. Access is possible via table index or table key. With a key access, the response time is directly dependent on the number of table entries. The key of a standard table is always non-unique.

<b>Sorted tables</b> are managed internally by means of a table index, too. They are always sorted by the table key and can be accessed via the table index or the table key. With a key access, the response time is logarithmically dependent on the number of table entries, because the table is accessed via a binary search. The key of sorted tables can be unique or non-unique.

<b>Hashed tables</b> are managed internally by a hash algorithm. Hashed tables can be accessed only via the table key. The repsponse time is constant, independent of the number of table entries. The key of hashed tables is always unique.

<b>Table Key</b> The table key is required for the identification of table rows. There are two possible keys for internal tables, the standard key and a user-defined key. The key can be declared as unique or non-unique, depending on the table category

<u><b>Internal Tables</b></u>

Internal tables are a way to store variable datasets of a fixed structure in the working memory of ABAP. The data is stored on a row-by-row basis, where each row has the same structure.

Internal tables provide the functionality of dynamic arrays and relieve the programmer of the expenditure of a program-controlled dynamic memory management.Internal tables are preferably used to store and format the content of database tables from within a program. Furthermore, internal tables in connection with structures are the most important means of defining very complex data structures in an ABAP program.

Former Member
0 Kudos

Hi Krishna,

Internal tables are a way to store variable datasets of a fixed structure in the working memory of ABAP. The data is stored on a row-by-row basis, where each row has the same structure.

Internal tables provide the functionality of dynamic arrays and relieve the programmer of the expenditure of a program-controlled dynamic memory management (see Memory management of deep data objects. Internal tables are preferably used to store and format the content of database tables from within a program. Furthermore, internal tables in connection with structures are the most important means of defining very complex data structures in an ABAP program.

A table type describes the structure and functional attributes of an internal table in ABAP.

A table type is defined by its line type, that defines the structure and data type attributes of a line of the internal table .

A table type defined in the ABAP Dictionary or using TYPES or DATA is fully specified by:

Row type ,Table category,table key etc.

Reward If useful

Regards

lavanya

Former Member
0 Kudos

HI,

1) A table type describes the structure and functional attributes of an internal table in ABAP. In ABAP programs you can reference a table type TTYP defined in the ABAP Dictionary with the command DATA <inttab> TYPE TTYP. An internal table <inttab> is created in the program with the attributes defined for TTYP in the ABAP Dictionary.

2) A table type is defined by:

its line type, that defines the structure and data type attributes of a line of the internal table

the options for managing and accessing the data ( access mode) in the internal table

the key ( key definition and key category) of the internal table

3) A table type is the data type of an internal table. It defines row type, table category, and table key of an internal table. The table can be generic regarding the key. A table type can be defined wit TYPES in an ABAP Program or in the ABAP Dictionary. In ABAP Dictionary, a table type must not be mixed up with database tables. The data type behind a database table is not a table type but a flat structure.

Just have a look at these links:

Regards,

Gunasree.

Former Member
0 Kudos

hi krishna chaitanya gogineni

refer the following link

http://allsaplinks.com/internal_tables_all.html