Skip to Content
avatar image
Former Member

Any FM or Tcode to find table columns list which contains data in it?

Hi Experts,

I want to know if there is any FM or tcode to fetch Table details and list of columns which all has data in it. like there is a FM DDIF_FIELDINFO_GET which gives the list and number of column present in the table. But i want list of only those columns which has data in it.



Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Dec 20, 2016 at 04:41 PM

    Hi Tanveer,

    Perhaps you should look around more... This is the NetWeaver Business Workflow community, and while we do use ABAP, I am pretty sure your question would get better answers under that tag.

    BTW, there is also Google. Type in something like ' DDIF_FIELDINFO_GET' or something similar. Give it a try!

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 20, 2016 at 07:52 PM

    And what purpose would this list possibly serve? On the rare occasions when the questions "do we have any values in this field?" arise they can be easily answered in SE16.

    There could be something available in the DB tools (ask your Basis admin or DBA) but I doubt it's something that the ABAPers would or should need on regular basis. Hence unlikely an FM already exists. You could write your own, of course, but again - why? What decisions would such information support?

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 20, 2016 at 10:25 PM

    Like Jelena suggested, it would nice to know what the ultimate goal is. For instance if you say the goal is to not display those fields to user, I would say use the class based ALVs. There are options there to not show empty columns. For instance using CL_GUI_ALV_GRID_EXT, you can use the method SET_HIDE_EMPTY_COLUMNS to control the visibility. I guess if you are desperate, you could debug this ALV class and see how SAP does it.

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 21, 2016 at 11:34 PM

    Try this - it will give you all Z Tables and the corresponding fields with a non blank value

    DATA: lt_dd03l  TYPE TABLE OF dd03l,
          ls_dd03l  TYPE dd03l,
          ref_struc TYPE REF TO data.
    FIELD-SYMBOLS: <any> TYPE any.
      FROM dd03l INNER JOIN dd09l ON dd03l~tabname = dd09l~tabname
      WHERE dd03l~tabname LIKE 'Z%'.
    LOOP AT lt_dd03l INTO ls_dd03l.
      UNASSIGN: <any>.
      DATA(lv_from) = ls_dd03l-tabname.
      DATA(lv_where) = ls_dd03l-fieldname && ` ` && 'NE' && ` ` && `''`.
          CREATE DATA ref_struc TYPE  (ls_dd03l-tabname).
          ASSIGN ref_struc->* TO <any>.
        CATCH cx_sy_create_data_error.
          SELECT SINGLE * INTO <any>
            FROM (lv_from)
            WHERE (lv_where).
        CATCH cx_sy_dynamic_osql_semantics cx_sy_dynamic_osql_syntax.
      IF sy-subrc IS INITIAL.
        WRITE:/ ls_dd03l-tabname, ` `, ls_dd03l-fieldname.
    Add comment
    10|10000 characters needed characters exceeded