ABAP Keyword Documentation → ABAP - Dictionary → Classic Objects in ABAP Dictionary → Database Tables
Global Temporary Tables
Global temporary tables (GTTs) are special transparent tables used as repositories for temporary data. This data exists only within a database LUW and can be accessed only by one consumer. GTTs are used to save temporary subtotals thereby splitting complicated database processes into multiple steps. GTTs are designed for this purpose only and hence incur far lower administration costs than regular transparent tables.
The GTT concept specifies that a GTT is always empty at the start of a database LUW and hence always has to be cleared at the end of each database LUW. Generally, database systems provide native support for this concept by defining data in a GTT database table as transaction-specific data implicitly. This data is deleted automatically at the end of a database LUW (in a database commit or database rollback).
In ABAP Dictionary, the table category global temporary table can be specified for a database table. Tables in this category have the variant GTT in the database. The following additional rules apply in ABAP SQL access to GTTs in ABAP Dictionary to avoid platform-dependent behavior and unexpected responses when handling GTTs:
- If an ABAP Dictionary GTT was filled by a modifying ABAP SQL statement, it must be cleared explicitly before the end of the current database LUW. The following can be used here:
- The ABAP SQL statement
DELETE FROM dbtab
without specifying aWHERE
condition.
- All explicit database commits and
database rollbacks, such as the ABAP SQL statements
COMMIT WORK
, COMMIT CONNECTION,ROLLBACK WORK
,ROLLBACK CONNECTION
plus all associated Native SQL statements and calls.
- If an ABAP Dictionary GTT filled using ABAP SQL was not cleared explicitly using one of these methods before an implicit database commit, the runtime error COMMIT_GTT_ERROR occurs independently of its content.
- The obsolete addition
CLIENT SPECIFIED
is forbidden. This includes the use ofCLIENT SPECIFIED
in queries and the use ofCLIENT SPECIFIED
inUPDATE SET
andDELETE FROM
. The non-obsolete form ofCLIENT SPECIFIED
in write statements is allowed.
Alongside these rules, GTTs can be used like regular transparent tables. With respect to their definition in ABAP Dictionary, the following settings have predefined values that cannot be modified:
- The data type and size category are ignored and undefined.
- Table buffering is not allowed.
- Logging is switched off.
- The storage type is row store.
- The delivery class is L.
- No replacement objects can be used.
The number of key fields of a GTT is limited to 15.
Other versions:
7.31 | 7.40 | 7.54
Notes
- When accessed using ABAP SQL, explicit clears of ABAP Dictionary GTTs are forced before implicit database commits for the following reasons:
- For making the program easier to understand. If an implicit database commit occurs within a programming module, for example due to an RFC, a developer may be surprised to find that the table is empty afterwards, since the database system deleted it implicitly at the end of the database LUW.
- It prevents errors caused by any platform dependencies. It cannot be guaranteed that every database platform deletes the data of a GTT in an implicit database commit. This is guaranteed, however, when the GTT is cleared explicitly.
- The statements COMMIT
WORK and
ROLLBACK WORK
clear the GTTs of all currently open database connections, whereasCOMMIT CONNECTION
andROLLBACK CONNECTION
only delete the GTTs of the specified connection.
- Only the variant
DELETE FROM dbtab
without aWHERE
condition specified prevents the runtime error COMMIT_GTT_ERROR. Other variants of theDELETE
statement do not prevent the runtime error, even if they clear the entire table.
- These additional rules apply only to writes using ABAP SQL. If a GTT is filled using only Native SQL or AMDP methods, no exceptions are raised in the case of implicit database commits. The GTT is then generally cleared by the database system. Conversely, using Native SQL or AMDP to clear a table filled using ABAP SQL does not prevent the runtime error COMMIT_GTT_ERROR.
- It is advisable to only use ABAP SQL to access ABAP Dictionary GTTs.
INSERT
statements with a subquery afterFROM
are particularly well suited for filling GTTs, since the operation is then performed only on the database and no data transports are required between the database and the AS ABAP.
- If the data of a GTT is only required when accessing a database, it is possible to make the corresponding request using common table expressions.
- When an ABAP Dictionary GTT is accessed using ABAP SQL, the syntax check is performed in a strict mode, which handles the statement more strictly than the regular syntax check.