简体   繁体   中英

How to list all tables in ABAP programmatically?

All tables may be listed with t-code SE16 and table DD02L. But how can that list be accessed programmatically?

It is rarely a good idea to access the database tables directly since you will have to deal with all kinds of technicalities you probably don't even know about - active / inactive versions, for example. You will also bypass all security and authorization checks, which might be irrelevant to you personally, but is undesirable in general. To get a list of tables, you can use the function module RPY_TABLE_SELECT . This function module will take care of the version handling and provide the description in the language of your choice as well.

Improved Alex code in some way and put it as an option:

SELECT tabname
 FROM DD02L 
 INTO TABLE @DATA(itab)
WHERE TABCLASS = 'TRANSP'.

LOOP AT itab ASSIGNING FIELD-SYMBOL(<FS>).
 WRITE:/ <FS>.
ENDLOOP.

Several things were refined: incline declarations were utilized, field-symbols added, SELECT * and WHERE IN were omitted and so on.
Also tables in SAP have only TRANSP class, INTTAB class belongs to structures.

Note: the sample is functional since ABAP 7.40, SP08.

An ongoing search resulted in the following snippet:

DATA ITAB TYPE TABLE OF DD02L.

SELECT * FROM DD02L INTO TABLE ITAB WHERE TABCLASS IN ('TRANSP', 'INTTAB').

WRITE :SY-SUBRC .

DATA FS TYPE DD02L.

LOOP AT ITAB INTO FS.

  WRITE:/ FS-TABNAME.

ENDLOOP.

Table description is given in table DD02T.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM