Skip to Content
Author's profile photo Former Member

Get the table names when you have your own field names

Business Scenario:

Sometimes you know the field names but you are not sure about the table names which contains your desired field names in that case you have to consult function person to help you out. So here is the program which gives you the table names whatever field names you give.

Note:  you can change the following code for your desired no. of fields, here I’m explaining with 2 fields

Note: Please handle validations and messages whenever you give wrong filed names or empty filed names. This program is just for reference.

REPORT  yh69_example.* Tables

TABLES dd02l.

* structure to hold table name and field name

TYPES:
      
BEGIN OF ty_data,
       tabname  
TYPE dd03ltabname,   ” Table name
       fieldname
TYPE dd03lfieldname, ” Field name
      
END OF ty_data.

* Declaration of internal tables to hold the table nameDATA:
       t_tab1
TYPE STANDARD TABLE OF ty_data,
       t_tab2
TYPE STANDARD TABLE OF ty_data,
       wa_tab1
TYPE ty_data,
       wa_tab2
TYPE ty_data.

PARAMETERS : p_filed1(30) TYPE c,
             p_filed2
(30) TYPE c.
” Get table names which contain your filed names

* Select

SELECT tabname
       fieldname
  
FROM dd03l
  
INTO TABLE t_tab1
  
WHERE fieldname EQ p_filed1
  
AND as4local  EQ ‘A’.
IF sysubrc EQ 0.

* Sort the table
 
SORT t_tab1 BY tabname.ENDIF.                                 ” IF SY-SUBRC EQ 0
” Get table names which contain your filed names

* Select

SELECT tabname
       fieldname
  
FROM dd03l
  
INTO TABLE t_tab2
 
WHERE fieldname EQ p_filed2
   
AND as4local  EQ ‘A’.
IF sysubrc EQ 0.

* Sort the table
 
SORT t_tab2 BY tabname.

ENDIF.                                 ” IF SY-SUBRC EQ 0
” Get tables names exist in both itab

LOOP AT t_tab2 INTO wa_tab2.

  READ TABLE t_tab1 INTO wa_tab1
                 
WITH KEY tabname = wa_tab2tabname.
 
IF sysubrc = 0.
   
SELECT SINGLE * FROM dd02l WHERE tabname  = wa_tab1tabname
                              
AND tabclass = ‘TRANSP’.
   
IF sysubrc EQ 0.
     
WRITE:/ wa_tab1tabname.
   
ELSE.
     
CLEARwa_tab1 .                ” CLEAR WORK AREA
   
ENDIF.                             ” IF SY-SUBRC EQ 0
 
ENDIF.                               ” IF SY-SUBRC EQ 0
 
CLEAR wa_tab2.                       ” CLEAR WORK AREA
ENDLOOP.

Assigned Tags

      8 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Chandramouli Reddy Nare
      Chandramouli Reddy Nare

      Pls use below code to get all transperent tables for specified fields...to acess for other conditions just change where statement

         DATA : itab TYPE STANDARD TABLE OF dd03vv WITH HEADER LINE.

      SELECT * FROM dd03vv INTO TABLE itab WHERE fieldname EQ 'KUNNR' OR fieldname EQ 'KTOKD' and tabclass = 'TRANSP'.
      SORT itab BY tabname fieldname.
      DELETE ADJACENT DUPLICATES FROM itab COMPARING tabname fieldname.
      LOOP AT itab WHERE fieldname = 'KUNNR'.
        READ TABLE itab WITH KEY tabname = itab-tabname fieldname = 'KTOKD' BINARY SEARCH.
        IF sy-subrc EQ 0.
          WRITE : / itab-tabname.
        ELSE.
          DELETE itab.
        ENDIF.
      ENDLOOP.

      Author's profile photo Thomas Zloch
      Thomas Zloch

      What is the added value, since the standard repository info system SE15 / SE90 can do this and much more?

      Thomas

      Author's profile photo Adi Sieker
      Adi Sieker

      Hi Thomas,

      I can't find a way to list all tables that contain a field with a specific name in se15. If you know how todo that a quick step-by-step post would be nice?
      I personally haven't had the need to find a table by one of it's field names, but it'd still be interesting.

      Cheers
         Adi

      Author's profile photo Thomas Zloch
      Thomas Zloch

      I would use the node "ABAP Dictionary - Fields - Table Fields" for this purpose, enter the field name(s) and leave table name blank. Takes a little time, obviously. There are additional selection criteria (click the respective button to see them) that allow a very flexible search.

      The standard program behind all this is SAPICDTF.

      Thomas

      Author's profile photo Adi Sieker
      Adi Sieker

      now that is to cool. I would have expected the functionality directly under ABAP Dictionary > Table.

      Adi

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Hi Thomas,

      As per the discussion between you and Adi Sieker, if it the case for searching for more than one field combination i can't able to find in SE15. so i tried for in this way and there may be  so many ways. thanks for your suggestions anyway.

      Regards

      Krishna Chaitanya

      Author's profile photo Former Member
      Former Member

      It seems I already saw this codes from somewhere but I'm glad you explained it nicely. 😉

      http://scn.sap.com/thread/3146643

      Cheers,

      Jake

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Hi Jake

      By seeing that post only i coded this program.  I don't know what other posts. anyway thank you.

      Thanks,

      chaitanya