How to filter the SAP tables by the number of fields?

491 Views Asked by At

SAP table DD02L lists, for each table in SAP, among others, the number of fields in each table. For example table, PLPO (PM task lists) contains 244 fields, according to T-Code S_PH0_48000138. For business reporting and using SQL, I only want to see 5, 6 field values at most, but the entire table is replicated, all 244 fields!

So, I want to know how many transparent tables consist of more than say, 20 fields. if I run the above t-code, it will take me 10 years, to do one table at a time.

Mike McNally

I am not an experienced ABAPer, so I do not know how to set this up.

1

There are 1 best solutions below

2
József Szikszai On

Table DD02L is "only" a list of all tables in SAP. I have not found any field in this table, which would tell, how many field the actual table has.

What could be used is table DD03L (SAP table fields), which lists all fields and tables in SAP. The fields are listed by position, which means we can select all tables where a field with position 21 exists (position 21 exists = there are more than 20 fields in the table):

SELECT FROM dd02l
       INNER JOIN dd03l
       ON dd02l~tabname  EQ dd03l~tabname  AND
          dd02l~as4local EQ dd03l~as4local AND
          dd02l~as4vers  EQ dd03l~as4vers
       FIELDS dd02l~tabname
       WHERE dd02l~tabclass EQ 'TRANSP' "only transparent tables
         AND dd03l~position EQ '0021'
       INTO TABLE @DATA(lt_dd02l).

The result (internal table lt_dd02l) will contain all the tables, which have more than 20 fields. I am on an R/3 system currently, the query took a few seconds only, but there are still over 12.000 tables with more than 20 fields.

*Answer edited after the comment from Gert Beukema (see below)