Internal Table Basics
Internal Table Basics
Discover more SAP ERP Database SAP ABAP Development for SAP HANA
HOME BASICS STATEMENT CONTROL BREAK DATABASE QUERY ADVANCE ABAP DOWNLOAD APPLICATION
SUBSCRIBE
Internal Table Basics LearnSapAbap
12:15 PM YouTube 5K
Internal table is a data object in ABAP that exists only at run time of a program. It means when the program
execution is complete then the internal table will be lost. We use internal table to store database table data after
fetching it by a select query. The ABAP run-time system dynamically manages the internal table’s memory. It
means we developer do not need to work on memory management of internal table.
GOOGLE TRANSLATE
Internal table has three parts – rows, columns & work area.
Select Language ▼
1. Rows are the line type of internal table. It is a structure which contains several fields. Those fields are
of data elements. We need to declare the structure locally or globally to declare the internal table.
2. Columns are the fields of internal table. Those fields are of different data elements declared by locally
or globally.
3. The most important part of an internal table is its work area. Work area is basically the line type of an SEARCH THIS BLOG
internal table. It means it has the same structure of the rows of internal table. Work area contains the
same fields of same type of the rows. It is of two types – implicit & explicit work area. Search
A. When we declare an internal table with header line then a work area is automatically
created with the same name of the table. This work area is called implicit work area which
is actually the header line. There is no need to declare work area separately. This work
area / header line contains the same table as of the internal table.
SLIDEBAR
Example –
TYPES: BEGIN OF ty_mat, Discover more SAP Database
matnr TYPE mara-matnr,
ABAP Development for SAP HANA
werks TYPE marc-werks,
lgort TYPE mard-lgort, SAP ERP ABAP for Hana
END OF ty_mat.
Here slis_qinfo_alv is a structure which has been declared globally in data dictionary. We
can declare the internal table directly with the table type also.
SUBSCRIBE
DATA: it_qinfo TYPE slis_t_add_fieldcat WITH HEADER LINE.
Extra Programs
https://www.learnsapabap.com/2017/09/internal-table-basics.html 1/4
9/26/25, 12:15 AM Internal Table Basics - LearnSapAbap
It also contains the same name IT_MAT but it is mentioned IT_MAT[ ] in the program.
B. If we declare an internal table without header line then we need to declare its work area Object Oriented ABAP -
seperately. Since we are declaring the work area explicitly it is called explicit work area. Events
This work area contains the different name from the internal table.
Example –
How to Display ALV table
TYPES: BEGIN OF ty_mat,
as pop up screen | ALV
matnr TYPE mara-matnr,
table | Display ALV output
werks TYPE marc-werks,
table.
lgort TYPE mard-lgort,
END OF ty_mat.
Similarly we can declare internal table with globally declared structure or table type also.
DATA: it_qinfo TYPE TABLE OF slis_qinfo_alv WITH NON- PAGEVIEWS PAST WEEK
UNIQUE KEY type.
DATA: it_qinfo TYPE slis_t_qinfo_alv.
4 0 2 1
Work area concept:
In today’s programming header line is not used in internal table. It is now obsolete. There are two main reasons
for that.
1. The automatically generated header line / implicit work area has the same name as of internal table.
That’s why it loses the readability of program.
2. When we use nested data objects (internal table has components of structure which is another internal
table) then header line is not allowed. In object oriented programming header line is not allowed.
To declare an internal table there is three basic specifications. They are 1. Row type, 2. Key & 3. Types of
internal table. Internal table is of three types – standard table, sorted table & hashed table. Standard &
sorted tables are called index table because we can access its records by its index. Index is nothing but a row
number of the internal table.
1. Standard table is an index table which has non-unique key. It can be accessed by index or key also. If
we want to access by key then the key must be defined otherwise default key would be considered.
The declaration is as follows:
DATA: it_mat TYPE STANDARD TABLE OF ty_mat WITH NON-UNIQUE KEY matnr.
OR
DATA: it_mat TYPE TABLE OF ty_mat WITH NON-UNIQUE KEY matnr.
If we don’t mention “Standard table of” clause then by default the system takes it as a standard internal
table. We can enter data into a standard internal table by using the APPEND statement. Append always
enters data at the last row of the table.
2. Sorted table is another kind of index table which has unique / non unique key. It also can be accessed
via index or key. For sorted table the key must be specified. The declaration is as follows:
DATA: it_mat TYPE SORTED TABLE OF ty_mat WITH UNIQUE KEY matnr,
it_mat TYPE SORTED TABLE OF ty_mat WITH NON-UNIQUE KEY matnr.
Unique key means the MATNR (material no) will must be unique. If same material number is inserted
then a run time error will happen. However we can declare the sorted table with non unique key also. In
https://www.learnsapabap.com/2017/09/internal-table-basics.html 2/4
9/26/25, 12:15 AM Internal Table Basics - LearnSapAbap
this case same material number can be entered but it will be sorted after entering the number. Here the
sorted table behaves similar to sorted standard table. We use INSERT statement to enter any records
to the sorted table.
3. Hashed table is not an index table. It follows the hash algorithm. Here the declaration of key is must
and also the key must be unique. Hence no duplicate entry will be in the hashed table. We can access
records only by the key.
DATA: it_mat TYPE HASHED TABLE OF ty_mat WITH UNIQUE KEY matnr.
Similar to sorted tables data can be inserted here by INSERT statement. Hashed tables are used when
the internal table contains huge volume of data.
RELATED POSTS
PREVIOUS NEXT
You are viewing Last Post Standard Internal Table
POST A COMMENT
No comments
Extra Programs
ABAP For Iteration with Where
condition | For Statement with
Where clause | For syntax with
Where condition
April 25, 2020
Object Oriented ABAP - Events
https://www.learnsapabap.com/2017/09/internal-table-basics.html 3/4
9/26/25, 12:15 AM Internal Table Basics - LearnSapAbap
Statement in SAP ABAP 7.40 | For
syntax in ABAP
April 19, 2020
https://www.learnsapabap.com/2017/09/internal-table-basics.html 4/4