An Internal table is a temporary table gets created in the memory of application server during program execution and gets destroyed once the program ends. It is used to hold data temporarily or manipulate the data. It contains one or more rows with same structure.


An internal table can be defined using the keyword TABLE OF in the DATA statement. Internal table can be defined by the following ways.
 
TYPES: BEGIN OF ty_student,
       id(5)    TYPE n,
       name(10) TYPE c,
       END OF ty_student.

DATA: gwa_student TYPE ty_student.

"Referring to local data type
DATA: it1 TYPE TABLE OF ty_student.
"Referring to local data object
DATA: it2 LIKE TABLE OF gwa_student.
"Referring to data type in ABAP dictionary
DATA: it3 TYPE TABLE OF mara.
Use the APPEND statement to add data to internal table. First define the work area i.e. define a field string with a structure similar to row of the internal table. Then place the data in the work area and use the APPEND statement to add the data from work area to internal table.
*--------------------------------------------------------------*
*Data Types
*--------------------------------------------------------------*
TYPES: BEGIN OF ty_student,
       id(5)    TYPE n,
       name(10) TYPE c,
       END OF ty_student.

DATA: gwa_student TYPE ty_student.

*--------------------------------------------------------------*
*Data Declaration
*--------------------------------------------------------------*
"Referring to local data type
DATA: it TYPE TABLE OF ty_student.

gwa_student-id    = 1.
gwa_student-name  = 'JOHN'.
APPEND gwa_student TO it.

gwa_student-id    = 2.
gwa_student-name  = 'JIM'.
APPEND gwa_student TO it.

gwa_student-id    = 3.
gwa_student-name  = 'JACK'.
APPEND gwa_student TO it.
 
After the last APPEND statement in the above program, internal table ‘IT’ has the following 3 entries. But the internal table values are not persistent i.e. the internal table and its values are discarded once the program ends.


Serkan AKKAVAK
Computer Engineer
ABAP Developer & SAP S/4 HANA Logistics Consultant
Contact : serkurumsal@yandex.com