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: 

Internal Table Structure

Former Member
0 Kudos
140

hi

i have an internal table itab with fields

f1(20) type c,

f2 type p,

f3 type p decimals 2,

f4 like mseg-matnr,

f5 like makt-maktx.

can i know the structure and dat type of the firleds at run time of an internal table..... like what we get thru FM <b>DDIF_FIELDINFO_GET</b>

Abhishek suppal

1 ACCEPTED SOLUTION

Former Member
0 Kudos
107

hi, except the CL_ABAP_XXXX class, you can also try this way:


DATA:BEGIN OF IT_TEST OCCURS 0,
      F1(20) TYPE C,
      F2 TYPE P,
      F3 TYPE P DECIMALS 2,
      F4 LIKE MSEG-MATNR,
      F5 LIKE MAKT-MAKTX,
END OF IT_TEST.
DATA: IT_RSTRUCINFO  TYPE STANDARD TABLE OF RSTRUCINFO.

CALL FUNCTION 'GET_COMPONENT_LIST'
     EXPORTING
          PROGRAM    = 'XXXX'   " your application name
          FIELDNAME  = 'IT_TEST'
     TABLES
          COMPONENTS = IT_RSTRUCINFO.

The internal table definition info will be restored in IT_RSTRUCINFO.

Hope it will be helpful

thanks

5 REPLIES 5

Former Member
0 Kudos
107

Hi Abhishek,

1. This can be done using Class/Object.

2. The required class (SE24) is

CL_ABAP_structDESCR.

3. Sample Program : (Just copy and paste)

REPORT typedescr_test.

*------- Variables

data : det type ref to CL_ABAP_structDESCR.

data : wa like line of det->components.

*------ Internal Table

DATA : BEGIN OF ITAB OCCURS 0,

MANDT TYPE T001-MANDT, "--- type

PERNR LIKE P0001-PERNR, " --- like

MATNR TYPE MARA-MATNR, "--- type

EBELN LIKE EKKO-EBELN, "--- like

END OF ITAB.

*----


Start of selection

START-OF-SELECTION.

det ?= cl_abap_typedescr=>describe_by_DATA( ITAB ).

loop at det->components into wa.

write 😕 wa-name , wa-type_kind , wa-length.

endloop.

*----


Number Of columns

describe table det->components.

write /: sy-tfill.

*----


hope the above helps.

Regards,

Amit M.

Former Member
0 Kudos
107

Abhishek,

You can use the methods of the class CL_ABAP_DATADESCR. The method is GET_DATA_TYPE_KIND.

Regards,

Ravi

Note : Please reward points if the posts are helpful.

Former Member
0 Kudos
108

hi, except the CL_ABAP_XXXX class, you can also try this way:


DATA:BEGIN OF IT_TEST OCCURS 0,
      F1(20) TYPE C,
      F2 TYPE P,
      F3 TYPE P DECIMALS 2,
      F4 LIKE MSEG-MATNR,
      F5 LIKE MAKT-MAKTX,
END OF IT_TEST.
DATA: IT_RSTRUCINFO  TYPE STANDARD TABLE OF RSTRUCINFO.

CALL FUNCTION 'GET_COMPONENT_LIST'
     EXPORTING
          PROGRAM    = 'XXXX'   " your application name
          FIELDNAME  = 'IT_TEST'
     TABLES
          COMPONENTS = IT_RSTRUCINFO.

The internal table definition info will be restored in IT_RSTRUCINFO.

Hope it will be helpful

thanks

0 Kudos
107

thanx zhenglin gu

Points given

Abhishek Suppal

Former Member
0 Kudos
107

Abhishek,

Simple way is to use DESCRIBE statement.

This will solve your problem.

Regards,

Amey