ERPClimb logoERPClimb
Internal Tables
ABAP Developmentadvanced 8 min read

Internal Tables Part 10: Memory Management and Large Internal Tables

Preview · a free account unlocks the full lesson

Key takeaway

Process large data volumes without memory dumps: estimate table size, select only needed columns, process in packages, free memory with FREE, avoid unnecessary copies, and analyze memory with the debugger and memory inspector.

In this lessonShow sections

Visual overview

Internal Tables Part 10: Memory Management and Large Internal Tables — learning sheetFlow: Compare the memory of SELECT * vs a field list for SBOOK (debugger memory view) → Rewrite a full load as package processing (code example) → FREE intermediate tables after use. Key ideas: HOW BIG IS MY TABLE?; SELECT ONLY WHAT YOU NEED; PACKAGE PROCESSING; AVOID COPIES. Watch out: Dump TSV_TNEW_PAGE_ALLOC_FAILED means the program exceeded its memory quota — design, don't just increase limits.ERPClimb.com / ABAP / LESSON 10/10 / LEARNING SHEETInternal Tables Part 10: Memory Management and LargeInternal Tables1 · HOW IT FLOWS1Compare the memory ofSELECT * vs a field listfor SBOOK (debugger…2Rewrite a full load aspackage processing (codeexample)3FREE intermediate tablesafter use2 · KEY IDEAS EXPLAINEDHow Big Is My Table?Row width = sum of field lengths (SBOOK * is muchwider than 5 selected fields).5 million rows × 200 bytes ≈ 1 GB — plus copies.Select Only What You NeedField list instead of SELECT *.WHERE conditions instead of filtering in ABAP.Package ProcessingSELECT … INTO TABLE gt_book PACKAGE SIZE 10000.Avoid CopiesAssigning a table to another variable sharesmemory until one is changed (copy-on-write) — thena full copy is made.Passing tables to methods by reference (defaultfor IMPORTING) avoids copies; VALUE( ) parameterscopy.3 · REMEMBER · WATCH OUTRememberMemory ≈ rows × row width — select only the columns you need.Process huge volumes in packages (SELECT … PACKAGE SIZE) instead ofloading everything.CLEAR/REFRESH empties a table but keeps memory; FREE releases it.!Watch outDump TSV_TNEW_PAGE_ALLOC_FAILEDmeans the program exceeded itsmemory quota — design, don't justincrease limits.4 · IN A REAL PROJECTA year-end archiving preparation program selected all fields of 30 million accounting line items into oneinternal table and dumped with TSV_TNEW_PAGE_ALLOC_FAILED. Basis was asked to raise memory quotas, which onlymoved the dump later. The redesign selected 8 needed fields, processed in packages of 50,000 rows, and wrote…Original ERPClimb learning sheet • Verify against your SAP release and edition

Explanation

Parts 1 through 9 made table processing correct and fast. With millions of rows, though, memory becomes the real limit, and this part looks at managing it.

A rough way to size a table is rows times row width, so it pays to select only the columns you actually need — a wildcard SELECT * against SBOOK is much wider than a query that picks five specific fields, and the difference matters at scale: five million rows at roughly 200 bytes each already comes to about 1 GB, before counting any copies of the table.

You can check this concretely in the debugger, where the table view shows the row count and the memory analysis shows the memory actually bound.

The first line of defense is simply selecting only what you need: a field list instead of SELECT *, WHERE conditions instead of filtering afterward in ABAP, and aggregating in the database with SUM, COUNT or GROUP BY rather than reading every row just to sum it in the program.

For genuinely large volumes, package processing avoids loading everything into memory at once: SELECT … INTO TABLE gt_book PACKAGE SIZE 10000. followed by code that processes gt_book — writing a file, posting, aggregating — inside the loop, ending with ENDSELECT. Only one package sits in memory at a time, and each iteration replaces the previous package's content, since using APPENDING TABLE to accumulate everything would defeat the whole purpose. The details of this technique are covered in Open SQL Part 7. Process huge volumes in packages instead of loading everything.

Free account

Create a free account to keep reading

You have read the opening of this lesson. A free ERPClimb account unlocks the rest of it, every other lesson and topic, and your learning history, so you can pick up exactly where you stopped. No card needed.

  • Full explanation
  • Code example
  • Real project scenario
  • Common mistakes
  • Best practices
  • Interview angle

One tap with Google works too. Every topic keeps its first lesson open to everyone.

Keep exploring

Referenced SAP objects

Reviewed reference pages for the objects this page mentions.

Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.