Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

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.

Thanks,

Thanveer

4 REPLIES 4

keohanster
Active Contributor
0 Kudos

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 'site:sap.com DDIF_FIELDINFO_GET' or something similar. Give it a try!
Sue

Jelena
Active Contributor
0 Kudos

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?

raghug
Active Contributor
0 Kudos

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.

former_member316436
Discoverer
0 Kudos

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.


SELECT * INTO CORRESPONDING FIELDS OF TABLE lt_dd03l
  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' && ` ` && `''`.


  TRY.
      CREATE DATA ref_struc TYPE  (ls_dd03l-tabname).
      ASSIGN ref_struc->* TO <any>.
    CATCH cx_sy_create_data_error.
      CONTINUE.
  ENDTRY.


  TRY.
      SELECT SINGLE * INTO <any>
        FROM (lv_from)
        WHERE (lv_where).
    CATCH cx_sy_dynamic_osql_semantics cx_sy_dynamic_osql_syntax.
      CONTINUE.
  ENDTRY.


  IF sy-subrc IS INITIAL.
    WRITE:/ ls_dd03l-tabname, ` `, ls_dd03l-fieldname.
  ENDIF.


ENDLOOP.