Table Type in SAP ABAP: Complete Guide to All Table Types

Types of Tables in SAP ABAP: Transparent, Cluster, and Buffer Tables Explained
At every level of SAP ABAP development, tables are essential. When developing a report, screen, or migrating data, identifying SAP ABAP tables is essential. SAP has a layered architecture of tables that range from persistent physical tables saved in ABAP Dictionary to ephemeral floating tables of ABAP.
This tutorial guide shows you everything about the types of SAP ABAP tables. It shows you how to construct, read, add, link, remove, delete tables and offers additional knowledge on the table maintenance generators, range tables, and CL_SALV_TABLE with BDC table control. Whether a new SAP ABAP developer or an experienced SAP ABAP developer preparing for a project, report, or project, this reference is for you.
Database Tables in SAP ABAP
ABAP works with three types of physical tables, that all have a designated place in ABAP Data Dictionary in SE11.
1. SAP ABAP Transparent Tables
The transparent table in SAP ABAP is the most common of the three table types. Data is saved in a database table with a direct association to it.
Identifying Features:
- Stored directly in the database with the dictionary object name
- Can be navigated using SE16 / SE16N
- Supports standard SQL functions (SELECT, INSERT, UPDATE, DELETE)
- Buffering is supported at the table level
- Can be used for the Master, Transaction, and Configuration data
Some standard SAP transparent tables are MARA (Material Master), KNA1 (Customer Master), and EKKO (Purchase Order Header).
Steps to create a transparent table in SAP ABAP (SE11):
- Navigate to transaction SE11
- Choose 'Database Table' and create a new entry (e.g.,
ZCUSTOM_TABLE) - Give a brief description
- Choose a Delivery Class (A for application data, usually)
- Define fields and begin with key fields, followed by data fields
- Choose the Enhancement Category
- Save, check, then Activate
2. SAP ABAP Cluster Table
An SAP ABAP cluster table does not have its own separate table within the database. Rather, multiple cluster tables are combined within a single physical database table known as a Table Cluster, particularly as the data is stored in a compressed binary format.
Identifying Features:
- Multiple logical tables use one physical database table
- Data is compressed and in a stored format that is not SQL accessible
- ABAP Open SQL (SELECT, INSERT) is required to access data
- Faster performance as a result of data being stored together
- Database JOINing to other tables is not possible
- Secondary indexes are not supported
Examples: BSEG (Accounting Document Line Items) stored in cluster RFBLG.
Cluster tables are being eliminated from SAP S/4HANA. BSEG is now a compatibility view on top of the new Universal Journal table ACDOCA.
3. Buffer Table (Pooled Table) in SAP ABAP
A buffer table (or a pooled table) in SAP ABAP is a table that does not have a one-to-one relationship with a database table. Many pooled tables are stored in a single database table, known as a Table Pool.
Some things to note:
- These are tables that are designed to have small amounts of flexible configuration and customizing data.
- They are stored in a compressed format.
- They can only be accessed with Open SQL.
- Some things that are not present are database JOINs and secondary indexes.
- They are designed to have fast read access.
- These tables are often used for SAP internal control tables.
For example, TSTC (Transaction Codes) and DDNTT (Data Dictionary objects).
Buffering in Transparent Tables
SAP supports table buffering for transparent tables to reduce the load on the database. This is independent of the table type.
- Full Buffering — The entire table is buffered on the application server the first time it is accessed.
- Generic Buffering — Part of the table (defined by key columns) is buffered.
- Single Record Buffering — Individual records are buffered.
Buffering can be configured in SE11 under the Technical Settings tab for a transparent table.
Internal Table in SAP ABAP
An internal table in the SAP ABAP programming language is an example of a data object defined at the program level. They hold data only in memory and are not present in the database. They are used to store sets of data that need to be manipulated, processed and sorted. The internal table also serves as a data structure that allows the developer to perform operations on the data within an ABAP program.
Common Internal Tables in SAP ABAP
Based on structure and access optimization, there are 3 categories of internal tables in SAP ABAP.
1. Standard Table
This is the most frequent internal table. Records are retained in their insertion sequence. Access is done via index (position) or search (key).
DATA: lt_materials TYPE STANDARD TABLE OF mara,
ls_material TYPE mara.
- Ideal for sequential actions (LOOP AT)
- Linear search is slower in comparisons of large tables
- Supports duplicate entries
2. Sorted Table
Records are upheld in sorted order, determined by the key. Access is typically faster than a standard table, due to binary search.
DATA: lt_sorted TYPE SORTED TABLE OF mara
WITH UNIQUE KEY matnr.
- Applies binary search to a key-based READ TABLE
- Fewer or no duplicate keys in a UNIQUE key
- Ideal for tables requiring sorted key access
3. Hashed Table in SAP ABAP
A hashed table in SAP ABAP is the best for a large lookup table. Access is only through the key using the hash algorithm.
DATA: lt_hashed TYPE HASHED TABLE OF mara
WITH UNIQUE KEY matnr.
- Access only by key — no index-based access
- Must have a UNIQUE key
- Ideal for large lookup tables requiring key access
- Cannot be looped indexed
Read Table in SAP ABAP
The READ TABLE statement retrieves the record and a key or index from an internal table.
In an ABAP program statement, if you want to read data for a specific key and do something with that record, you can follow the example below.
READ TABLE lt_materials INTO ls_material
WITH KEY matnr = '000000000000100002'.
IF sy-subrc = 0.
WRITE: / ls_material-matnr, ls_material-mbrsh.
ENDIF.
" Read by index
READ TABLE lt_materials INTO ls_material INDEX 1.
With the introduction of ABAP 7.4, a bamboo style for inline read was introduced. It allows to achieve the same result but in a more concise way as below.
READ TABLE lt_materials
WITH KEY matnr = lv_matnr
INTO DATA(ls_mat).
" Table expression (raises an exception if the value is correct)
DATA(ls_mat2) = lt_materials[ matnr = lv_matnr ].
" Safe access with REF (not so short dump)
DATA(lr_mat) = REF #( lt_materials[ matnr = lv_matnr ] OPTIONAL ).
In the same way ABAP 7.4 expressions have a simpler and more minimal approach.
Describe Table in SAP ABAP
The DESCRIBE TABLE command is a SAP ABAP command to find the metadata of an ABAP table, especially, the number of rows it holds and the table type it is.
DATA: lv_lines TYPE i,
lv_kind TYPE c.
DESCRIBE TABLE lt_materials
LINES lv_lines
KIND lv_kind.
WRITE: / 'Lines:', lv_lines.
WRITE: / 'Kind:', lv_kind. " S=Standard, H=Hashed, O=Sorted
From ABAP 7.4, a more concise and simpler approach is speaking:
DATA(lv_lines) = lines( lt_materials ).
Range Table in SAP ABAP
In ABAP, a range table works the same as the selection screen in ABAP to hold the user selection box (from box, to, etc.) value meant for the system to hold it in an ABAP internal table (has a structure of 4 fields: SIGN, OPTION, LOW, HIGH).
DATA: lt_matnr TYPE RANGE OF matnr_d,
ls_range LIKE LINE OF lt_matnr.
ls_range-sign = 'I'.
ls_range-option = 'BT'.
ls_range-low = '000000000000100000'.
ls_range-high = '000000000000100099'.
APPEND ls_range TO lt_matnr.
" Use in SELECT
SELECT * FROM mara
INTO TABLE @DATA(lt_result)
WHERE matnr IN @lt_matnr.
Range tables allow you to set dynamic filter criteria for use in SELECT statements or within function modules.
Check Table and Value Table in SAP ABAP
These two terms pertain to foreign key structures in the ABAP Dictionary.
Check Table in SAP ABAP
A check table in SAP ABAP serves to check the input values of a field from another table. The check table is the table that is pointed to by the foreign key. For example, SAP validates the input of values in the screen fields based on the check table.
Example: In the custom table, for the Plant field (WERKS), if you are pointing to T001W, it must be a value of T001W.
Value Table in SAP ABAP
An SAP ABAP value table is defined at the domain level within SE11. This is the particular table that contains all the valid values for the domain. Thus, if a foreign key is created for a field at that particular domain, the SAP system recommends this value table as the check table.
This means the value table is a recommendation at the domain level, while a check table is an enforced relationship at the field level.
How to Insert Data into Custom Table in SAP ABAP
Data insertion into custom tables created in SAP ABAP is done through INSERT, MODIFY, or UPDATE statements.
ls_zcustom-mandt = sy-mandt.
ls_zcustom-zid = '001'.
ls_zcustom-zname = 'Test Record'.
ls_zcustom-zdate = sy-datum.
INSERT zcustom_table FROM ls_zcustom.
IF sy-subrc = 0.
COMMIT WORK.
MESSAGE 'Record inserted successfully.' TYPE 'S'.
ELSE.
ROLLBACK WORK.
MESSAGE 'Insert failed.' TYPE 'E'.
ENDIF.
Insert multiple records:
INSERT zcustom_table FROM TABLE lt_zcustom.
Delete from Table SAP ABAP
Delete records from zcustom_table:
DELETE FROM zcustom_table
WHERE zid = '001'.
DELETE zcustom_table FROM ls_zcustom.
Deletions in an Internal Table in SAP ABAP
" To delete a record from lt_materials
DELETE lt_materials WHERE matnr = '000000000000100002'.
" Remove the record at index 3
DELETE lt_materials INDEX 3.
" To delete all entries and reset memory
CLEAR lt_materials.
" To delete all entries and release memory
FREE lt_materials.
How to Join Two Tables in SAP ABAP
To join two tables in SAP ABAP, the supported join types are INNER and OUTER. You can use INNER JOIN and LEFT OUTER JOIN in Open SQL. Here is an Inner Join of Tables MARA and MAKT.
SELECT a~matnr, a~mbrsh, b~maktx
FROM mara AS a
INNER JOIN makt AS b
ON a~matnr = b~matnr
WHERE b~spras = @sy-langu
INTO TABLE @DATA(lt_result).
For a LEFT OUTER JOIN:
SELECT a~matnr, a~mbrsh, b~maktx
FROM mara AS a
LEFT OUTER JOIN makt AS b
ON a~matnr = b~matnr
AND b~spras = @sy-langu
INTO TABLE @DATA(lt_result2).
Note: Database JOINs are not permitted using cluster tables and pooled tables. Always use transparent tables.
Table Maintenance Generator in SAP ABAP
The Table Maintenance Generator (SE54) in SAP ABAP simplifies the process of creating a maintenance dialog for any custom table in the database. A function group included with logic and screens is created and end users are able to modify the table entries via a default interface. There is no need for any ABAP development. The generation of the table maintenance dialog can be done in the following steps:
- Establish and activate the necessary transparent table in SE11.
- Head into SE54 (could also be done by navigating SE11 → Utilities → Table Maintenance Generator).
- Insert the table name.
- Choose the 'Create' under 'Generate Objects' option.
- Assign the Function group name (i.e.,
ZCUSTOM_TABLE_MG). - Choose the authorization group (
&NC&, could be set for no authorization check during the development phase). - Choose the desired maintenance type, for instance, One Step (single screen) or Two Step (overview + detail).
- Generate.
End users can utilize the maintenance view that is generated through transaction SM30.
CL_SALV_TABLE in SAP ABAP
CL_SALV_TABLE is a class used to build an ALV grid report by displaying the contents of an internal table. A specific instance of the class is required, along with data that is configured as a table control. The default method for displaying the grid report is REUSE_ALV_GRID_DISPLAY.
To create a class instance, the embedded scenario can be used.
DATA: lo_alv TYPE REF TO cl_salv_table,
lo_cols TYPE REF TO cl_salv_columns_table.
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = lo_alv
CHANGING
t_table = lt_result ).
lo_cols = lo_alv->get_columns( ).
lo_cols->set_optimize( abap_true ).
lo_alv->display( ).
CATCH cx_salv_msg INTO DATA(lx_error).
MESSAGE lx_error->get_text( ) TYPE 'E'.
ENDTRY.
CL_SALV_TABLE is preferred in modern ABAP development for its built-in sorting/filtering, easy column configuration, and OOP syntax.
BDC Table Control in SAP ABAP
BDC table control in SAP ABAP deals with the table elements in the respective screen sections of the SAP system. Each of these row elements needs to be added or addressed individually in BDC playback. This is what requires special handling for table controls.
For example, when a BDC is recorded for a transaction that has table control, say ME21N for example, what the recording captures will be a single field with a row reference, such as EKPO-MATNR[1,17]. In the ABAP BDC program, the table is looped and a BDC table is constructed (BDCDATA) with field names that are dynamically created.
A key refinement of this business process is:
FORM bdc_field USING fnam fval.
CLEAR gs_bdcdata.
gs_bdcdata-fnam = fnam.
gs_bdcdata-fval = fval.
APPEND gs_bdcdata TO gt_bdcdata.
ENDFORM.
This is called using a dynamic row index.
DATA(lv_field) = |EKPO-MATNR[{ lv_row },17]|.
PERFORM bdc_field USING lv_field ls_item-matnr.
It is critical to thoroughly test BDC table control programs across varying screen resolutions.
Standard SAP ABAP Tables
Standard SAP ABAP tables include:
- The STANDARD TABLE type of internal tables (default, access is via the index).
- SAP delimited database tables included in the pre-configured SAP system (e.g., MARA, VBAK, KNA1).
- Developers use the term "standard tables" to refer to SAP deliverables, transparent tables provided in the system that are not meant to be adjusted, where custom modifications to these tables are applied via an append structure or an extended include of the table, instead of direct adjustments to the table.
Guidelines on Utilizing Tables in ABAP
- Forced or hashed tables should be used for key-based, repetitive lookups on sets of data that reside in main memory.
- Loops inside of implementation blocks of code should be avoided in favor of JOINs or FOR ALL ENTRIES commands.
- When planted tables to be used are sorted by key, use READ TABLE ... BINARY SEARCH commands, if, for whatever reason, constrained to utilize planted tables of sorted or hashed type.
- Consistently check for
sy-subrcafter READ TABLE, SELECT SINGLE commands, and database operations. - Use FREE command over CLEAR when large internal tables are to be freed up.
- For new development, ABAP 7.4 or more recent inline syntax should be retained.
- For tables, buffering should always be activated in the technical settings.
Common Queries
Outline the Key Differences between Transparent and Cluster Tables in ABAP?
The transparent table is a direct mapping of a database table. They provide the possibility of direct access to SQL. A cluster table, is, in turn, stored in the framework of a table designed for accessing clustered tables along with some alphates of other clustered tables, and thus can only be used with the implementation of the ABAP Open SQL.
Are internal tables to be used in SELECT statements?
To utilize SELECT FROM clauses, one may not use internal tables. However, database views and clauses SELECT FROM commands may be employed, Open SQL, or more elaborate commands. LISTs may be used for database coercions.
What is the main difference between CLEAR and FREE commands for internal tables?
There is a significant difference between the commands FREE and CLEAR for internal tables. While using CLEAR lt_table will clear the internal table and keep the memory allocated, using FREE lt_table will clear the table and release the memory allocated. Hence, FREE should be used for large tables.
What is the purpose of the Table Maintenance Generator?
The Table Maintenance Generator (SE54) helps create a maintenance user interface for custom database tables so that end users can see, add, modify, and delete the entries of a table using the transaction SM30 with no need for a custom ABAP program.
When should I opt for a hashed table over a standard table?
When you only need a large internal table for key-based search operations (READ TABLE WITH KEY), then you only need a hashed table. Hashed tables provide direct access to key-based search operations thanks to their O(1) time complexity. This is a huge advantage over standard (i.e., table with a search of linear complexity) and sorted table (i.e., table with a search of a log-n complexity) with a key-based search.
Conclusion
A basic skill for all SAP developers is understanding the wide range of tables used in SAP ABAP (physical database tables like transparent, clustering, and buffering tables and in-memory standard, sorted and hashed internal tables). However, with basic table types and skills in reading, joining, and deleting table data, and using INSERT and DELETE statements along with Range Tables and CL_SALV_TABLE, and using Table Maintenance Generator, you are set for real SAP ABAP professional development.
This guide will teach you lessons relevant to all projects and modules. Whether you are working with ECC or S/4HANA, the concepts discussed in this guide will apply to all layers of the SAP technology stack.
Related SAP Training Courses
Tags
Share this article
Help others discover this valuable SAP content


