Skip to Content
Author's profile photo Former Member

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 🙂

Assigned Tags

      10 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Good One...Many Thanks.

      Best Regards,

      Naresh K.

      Author's profile photo Anson Abraham
      Anson Abraham

      Hi Daniel Yacouboff

      Very nice info.

      Thanks for sharing 🙂

      BR,

      Anson

      Author's profile photo Former Member
      Former Member

      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

      Author's profile photo Former Member
      Former Member

      Anurag,

      Thanks for the enlightment 🙂

      Author's profile photo Former Member
      Former Member

      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.

      Author's profile photo Former Member
      Former Member

      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...

      Author's profile photo Former Member
      Former Member

      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

      Author's profile photo Former Member
      Former Member

      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...

      Author's profile photo Former Member
      Former Member

      Thanks for the Information.

      Please also check DD03N View.

      Regards,

      Ravi Pratap Singh

      Author's profile photo Former Member
      Former Member

      Thanks for sharing