List SAP Tables by ABAP Code
ABAP tutorial shares programmers ABAP codes to list SAP tables from DD02L - SAP Tables ABAP table. By querying DD02L system table, it is possible for developers to reach all SAP table information.
ABAP Code to List SAP Tables
All tables created are recorded in an other SAP table named DD02L - SAP Tables
By querying DD02L table, ABAP programmer can get the list of SAP tables on the current SAP system and filter according to search criteria.
SELECT tabname INTO TABLE @DATA(gt_saptable)
FROM dd02l
WHERE tabclass = 'TRANSP'
ORDER BY tabname.
" possible Table category options
*TRANSP Transparent table
*INTTAB Structure
*CLUSTER Cluster table
*POOL Pooled table
*VIEW General view structure
*APPEND Append structure
LOOP AT gt_saptable REFERENCE INTO DATA(gr_saptable).
WRITE:/ gr_saptable->tabname.
ENDLOOP.
ABAP programmers can use above ABAP code to get the list of transparent SAP tables.
Using a pointer with REFERENCE INTO hint all SAP tables can be written on screen in an ABAP Loop statement.
ABAP codes to list SAP Tables
List of SAP Tables and Descriptions
IF ABAP programmer joins the "DD02L SAP Tables" with "DD02T - SAP DD: SAP Table Texts" on field TABNAME (Table Name), the description or text description of each table can be fetched programmatically.
SELECT dd02l~tabname dd02t~ddtext
INTO TABLE @DATA(gt_saptable_text)
FROM dd02l
INNER JOIN dd02t ON dd02t~tabname = dd02l~tabname
WHERE tabclass = 'TRANSP' AND ddlanguage = 'E'
ORDER BY dd02l~tabname.
LOOP AT gt_saptable_text REFERENCE INTO DATA(gr_saptable_text).
WRITE:/ gr_saptable_text->tabname, gr_saptable_text->ddtext.
ENDLOOP.