Get the data types of all fields in a table
Hello everyone,
After some research I’ve managed to find an answer to my own question here:
http://scn.sap.com/thread/3412096
and I would like to share this with you.
Basically, in oder to find the types of all fields of a given table, just make the following query to table DD03L:
SELECT tabname fieldname rollname
INTO TABLE some_table
FROM DD03L
WHERE tabname = some_name.
BUT, sometimes, fields might be either a structure, or a table as well (deep table\structure). In those cases, we need to select the field type from tables DD03M (if structure) or DD40L (if table). Here are examples:
SELECT typename rowtype
INTO TABLE some_other_table
FROM DD40L
WHERE typename = some_row_from_some_table-rollname.
OR
SELECT tabname fieldname rollname domname
INTO TABLE some_other_different_table
FROM DD03M
WHERE tabname = some_row_from_some_table-rollname.
Note the differences between the two queries.
Any additions, corrections, or maybe a name of an existing function that does all that faster and easier, will be appericiated!
Hope that helps someone 🙂
Good One...Many Thanks.
Best Regards,
Naresh K.
Hi Daniel Yacouboff
Very nice info.
Thanks for sharing 🙂
BR,
Anson
Hi Daniel,
Great topic to highlight, there is one framework class CL_ABAP_TYPEDESCR for the same. and i would suggest that one could use Classes to read the meta data instead of using the tables directly.
Regards
Anurag Chopra
Anurag,
Thanks for the enlightment 🙂
FM "DDIF_TABL_GET" can also be used to get the field name, domain name, data type and length. not only these fields it fetches more data about the given table.
Hi Syed,
This does the first step of finding the types and domains of a table fields.
Though, if a certain field is also a table, it doens't show the types of its components...
yah it doesn't show the fields of the table types, but the value in the data type field will be TTYP. and you can use the same FM with TTYP name
That's exactly the thing - that it doesn't. I've tried with an example of my own table with tables in it...that's why the need for a program like mine came up...
Thanks for the Information.
Please also check DD03N View.
Regards,
Ravi Pratap Singh
Thanks for sharing