📊

Understanding Global Temporary Tables in ABAP

Jan 6, 2025

Global Temporary Tables (GTTs) in ABAP

Overview

  • GTTs are special transparent tables for temporary data.
  • Data exists only within a database Logical Unit of Work (LUW).
  • Accessible by only one consumer.
  • Used to save temporary subtotals, splitting complex processes.
  • Lower administration costs compared to regular tables.

Key Characteristics

  • Always Empty at Start: GTTs are empty at the start of a database LUW.
  • Clearing Required: Must be cleared at the end of each LUW.
    • Automatic deletion at the end of a LUW (commit or rollback).

Usage in ABAP Dictionary

  • Table Category: Specified as global temporary table.
  • Additional Rules: Ensure platform-independent behavior and prevent unexpected responses.
    • Explicit Clearing Required:
      • Use DELETE FROM dbtab without WHERE for clearing.
      • Use explicit commits and rollbacks (COMMIT WORK, ROLLBACK WORK).
      • Runtime error COMMIT_GTT_ERROR if not cleared before implicit commit.
    • Restrictions:
      • USING CLIENT and CLIENT SPECIFIED not allowed.
  • Predefined Settings:
    • Data type and size category ignored.
    • Table buffering not allowed.
    • Logging switched off.
    • Storage type is row store.
    • Delivery class is L.
    • No replacement objects.
    • Key fields limited to 15.

Notes on Usage

  • Explicit Clear Required: Prevents errors and makes programs clear.
    • Ensures data is deleted implicitly by the system.
    • COMMIT WORK and ROLLBACK WORK clear all connections, while COMMIT CONNECTION and ROLLBACK CONNECTION only affect specified connections.
    • Only DELETE FROM dbtab without conditions prevents COMMIT_GTT_ERROR.
  • Exceptions:
    • Rules apply only to ABAP SQL writes.
    • Using Native SQL or AMDP does not raise exceptions on implicit commits.
    • Advisable to use ABAP SQL for ABAP Dictionary GTTs.
  • Filling GTTs:
    • INSERT with a subquery from FROM is efficient.
    • Data requests can be optimized using common table expressions.
  • Syntax Check: Strict mode for checking ABAP SQL access.

Example Usages

  • Global Temporary Tables, Access.
  • Union with Global Temporary Table. Image Example