Skip to content
IT Canvass
SAP ABAP development · Lesson

Internal tables

Quick answer

Choose the table type for the access pattern: hashed/sorted tables make repeated lookups dramatically faster than linear reads on a standard table.

Key takeaways

  • An internal table holds multiple rows of a structured type in memory, think of it as a temporary table your program builds and…
  • Standard: general purpose, indexed access.
  • Sorted: kept in key order, fast binary-search reads.
  • Watch out: Linear READ in a loop on a big standard table; use sorted/hashed.

What an internal table is

An internal table holds multiple rows of a structured type in memory, think of it as a temporary table your program builds and processes. You SELECT database rows into an internal table, then loop, read, sort, filter and aggregate in memory, which is fast and central to nearly every report and interface.

Table types

  • Standard: general purpose, indexed access.
  • Sorted: kept in key order, fast binary-search reads.
  • Hashed: keyed, near-constant-time single-row access for large lookups.

Core operations

DATA lt_mara TYPE STANDARD TABLE OF mara.
SELECT * FROM mara INTO TABLE @lt_mara UP TO 100 ROWS.

SORT lt_mara BY matnr.
READ TABLE lt_mara INTO DATA(ls) WITH KEY matnr = 'X' BINARY SEARCH.
DELETE lt_mara WHERE mtart = 'ROH'.
DATA(lv_count) = lines( lt_mara ).

Performance choices

Choose the table type for the access pattern: hashed/sorted tables make repeated lookups dramatically faster than linear reads on a standard table. For big lookups inside loops, a hashed table (or sorted with binary search) instead of a repeated linear READ is a major optimisation.

Common pitfalls

  • Linear READ in a loop on a big standard table; use sorted/hashed.
  • Wrong table type for the access pattern.
  • Reading the DB per row instead of into a table once.

Want to learn this properly?

Our live, instructor-led SAP Training covers this hands-on, with real projects and a certification path.

Check your understanding

  1. Which statement is true of Internal tables?

    • A. The software prerequisites for an SAP installation, the operating system, database, kernel, and supporting…
    • B. ECC (SAP ERP Central Component) release notes cover the previous-generation ERP, delivered largely through…
    • C. You SELECT database rows into an internal table, then loop, read, sort, filter and aggregate in memory, which…
    Show answer

    C. You SELECT database rows into an internal table, then loop, read, sort, filter and aggregate in memory, which…

    Covered in the “What an internal table is” section of this lesson.

  2. Which of these also applies to Internal tables?

    • A. Confusing storage location with WM bins, different levels of detail.
    • B. For big lookups inside loops, a hashed table (or sorted with binary search) instead of a repeated linear READ…
    • C. Following steps without understanding the concept.
    Show answer

    B. For big lookups inside loops, a hashed table (or sorted with binary search) instead of a repeated linear READ…

    Covered in the “Performance choices” section of this lesson.

  3. Which part of the Learn SAP curriculum covers Internal tables?

    • A. SAP ABAP development
    • B. SAP architecture
    • C. SAP modules hub
    Show answer

    A. SAP ABAP development

    This lesson sits in the SAP ABAP development section of the Learn SAP course.

Frequently asked questions

What does the term Internal tables refer to in SAP?

Internal tables are ABAP’s in-memory tables, the central data structure for working with sets of rows (like query results) inside a program. Mastering internal tables is arguably the most important ABAP skill.

What is worth remembering about Internal tables in practice?

Choose the table type for the access pattern: hashed/sorted tables make repeated lookups dramatically faster than linear reads on a standard table.

What is another point to note about Internal tables?

An internal table holds multiple rows of a structured type in memory, think of it as a temporary table your program builds and processes.

What tends to go wrong with Internal tables?

Linear READ in a loop on a big standard table; use sorted/hashed. Wrong table type for the access pattern. Reading the DB per row instead of into a table once.
CallWhatsAppEnquire