An internal table in SAP ABAP is a dynamic data object used to store and process multiple records of the same structure in the application server's working memory (RAM) during program runtime. Unlike persistent database tables, internal tables are temporary; they exist only while the program executes and are discarded immediately after it finishes. They function similarly to arrays or vectors found in other programming languages. Internal Tables mimic the behavior of dynamic arrays or database tables, allowing developers to manipulate multi-row data without continuously querying the database, reducing server traffic.
Essential Internal Table Operations
1. Adding Records
APPEND: Adds a row to the end of a Standard Table. Avoid using it on Sorted or Hashed tables.
INSERT: Inserts a row into a specific position, or lets the system place it automatically based on the unique key in Sorted/Hashed tables.
2. Reading Records
READ TABLE (Traditional): Copies a single row into a work area.
Table Expressions (Modern ABAP 7.40+): Offers a sleek, readable alternative to traditional statements.
3. Looping and Processing Rows
LOOP AT: Iterates through the lines of the table. Using ASSIGNING with a field symbol modifies the table directly in memory, which is faster than copying rows into a work area.
4. Deleting and Clearing Data
DELETE: Drops specific entries based on a key condition or an index.
CLEAR or REFRESH: Wipes all content out of the internal table, resetting its row count back to zero.
FREE: empties the table and immediately releases the memory allocation back to the operating system [2]. Use FREE if you are finished with a large table and want to prevent memory overflows (TSV_TNEW_PAGE_ALLOC_FAILED).