Application Development and Automation 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: 
Read only

Find fields of a table programatically

Former Member
0 Likes
582

Hello All,

is there any way to find out all fields of a table programatically ...?

Like if VBAK is give ...i need the list of all standard and custom fields of that table

Regards,

KK

1 ACCEPTED SOLUTION
Read only

former_member156446
Active Contributor
0 Likes
543

Hi Tcode

if you write a simple select on DD03L and DD03T your problem is solved.

else you have a FM:

TABLES: DFIES,
        X030L.

DATA: BEGIN OF INTTAB OCCURS 100.
        INCLUDE STRUCTURE DFIES.
DATA: END OF INTTAB.

PARAMETERS: TABLENM TYPE DDOBJNAME       DEFAULT 'MSEG',
            FIELDNM TYPE DFIES-FIELDNAME DEFAULT 'MENGE'.

      call function 'DDIF_FIELDINFO_GET'
        exporting
          tabname              = TABLENM
          FIELDNAME            = FIELDNM
          LANGU                = SY-LANGU
*         LFIELDNAME           = ' '
*         ALL_TYPES            = ' '
*       IMPORTING
*         X030L_WA             = WATAB
*         DDOBJTYPE            =
*         DFIES_WA             =
*         LINES_DESCR          =
        TABLES
          DFIES_TAB            = INTTAB
*         FIXED_VALUES         =
        EXCEPTIONS
          NOT_FOUND            = 1
          INTERNAL_ERROR       = 2
          OTHERS               = 3.

      if sy-subrc <> 0.
         WRITE:/ 'Field name not found'.
      endif.

      LOOP AT INTTAB.
         WRITE:/ INTTAB-TABNAME, INTTAB-FIELDNAME, INTTAB-FIELDTEXT.
      ENDLOOP.

This FM will help u too..

MSS_MON_TABLE_COLUMNS

3 REPLIES 3
Read only

Former Member
0 Likes
543

Please search the forum. This question has been answered many times.

Rob

Read only

Former Member
0 Likes
543

I just searched with GETTABLEFIELDS>F4 in SE37 , i got my answer.

Read only

former_member156446
Active Contributor
0 Likes
544

Hi Tcode

if you write a simple select on DD03L and DD03T your problem is solved.

else you have a FM:

TABLES: DFIES,
        X030L.

DATA: BEGIN OF INTTAB OCCURS 100.
        INCLUDE STRUCTURE DFIES.
DATA: END OF INTTAB.

PARAMETERS: TABLENM TYPE DDOBJNAME       DEFAULT 'MSEG',
            FIELDNM TYPE DFIES-FIELDNAME DEFAULT 'MENGE'.

      call function 'DDIF_FIELDINFO_GET'
        exporting
          tabname              = TABLENM
          FIELDNAME            = FIELDNM
          LANGU                = SY-LANGU
*         LFIELDNAME           = ' '
*         ALL_TYPES            = ' '
*       IMPORTING
*         X030L_WA             = WATAB
*         DDOBJTYPE            =
*         DFIES_WA             =
*         LINES_DESCR          =
        TABLES
          DFIES_TAB            = INTTAB
*         FIXED_VALUES         =
        EXCEPTIONS
          NOT_FOUND            = 1
          INTERNAL_ERROR       = 2
          OTHERS               = 3.

      if sy-subrc <> 0.
         WRITE:/ 'Field name not found'.
      endif.

      LOOP AT INTTAB.
         WRITE:/ INTTAB-TABNAME, INTTAB-FIELDNAME, INTTAB-FIELDTEXT.
      ENDLOOP.

This FM will help u too..

MSS_MON_TABLE_COLUMNS