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

Getting internal Table information

former_member810660
Participant
0 Likes
821

Hi Experts,

i want to know, how to get the internal tables uesd in a program and how to get the field lenghts and names of each field in that internal table.



REPORT zktest MESSAGE-ID zi LINE-COUNT 60.
      DATA: BEGIN OF line,
         col1 TYPE i,
         col2 TYPE i,
      END OF line.

DATA: itab1 TYPE TABLE OF line WITH HEADER LINE INITIAL SIZE 0.

if i have an internal table like this, i need to get , what are the internal tables used in the program and have to get the field lenghts of <b>col1 col2</b> under the table itab1.

i need to get this information within the same program, to get the table informations that i have used.

any suggestions and clues are appreciated.

Thanks & Regards,

Poorna.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
787

Hi Poorna,

To get the runtime details of any variable there is a RTTI functins available.

for your querry checkout the cl_abap_structdescr class and its usage.

You need to create a structure variable as

Data itab1_struct like itab1.

and then call the abovt method with itab1_struct as an exporting parameter in the call statement.

In return you will get name,kind,length of the individual components of the structure you want to know at runtime.

Explore more in the RTTI (Real Time Type Identification) functionality in the help documentations for other details.

Regds,

Gaurav

7 REPLIES 7
Read only

Former Member
0 Likes
787

HI

select that name of the internal table and follw this path

UTILITIES -> WHERE USED LIST

you will get one pop up and select program option there

it will show all the programs in which it is used

Read only

Former Member
0 Likes
787

u can simply use find button in programand select main program check box. click on data declarations.

Read only

Former Member
0 Likes
788

Hi Poorna,

To get the runtime details of any variable there is a RTTI functins available.

for your querry checkout the cl_abap_structdescr class and its usage.

You need to create a structure variable as

Data itab1_struct like itab1.

and then call the abovt method with itab1_struct as an exporting parameter in the call statement.

In return you will get name,kind,length of the individual components of the structure you want to know at runtime.

Explore more in the RTTI (Real Time Type Identification) functionality in the help documentations for other details.

Regds,

Gaurav

Read only

Former Member
0 Likes
787

try out with following code.

you need to use DESCRIBE statement to have internal table details.

DATA: BEGIN OF LINE,

COL1 TYPE I,

COL2 TYPE I,

END OF LINE.

DATA ITAB LIKE HASHED TABLE OF LINE WITH UNIQUE KEY COL1

INITIAL SIZE 10.

DATA: LIN TYPE I,

INI TYPE I,

KND TYPE C.

<b>DESCRIBE TABLE ITAB LINES LIN OCCURS INI KIND KND.</b>

WRITE: / LIN, INI, KND.

DO 1000 TIMES.

LINE-COL1 = SY-INDEX.

LINE-COL2 = SY-INDEX ** 2.

INSERT LINE INTO TABLE ITAB.

ENDDO.

<b>DESCRIBE TABLE ITAB LINES LIN OCCURS INI KIND KND.</b>

WRITE: / LIN, INI, KND.

Read only

Former Member
0 Likes
787

Hi,

To get internal table info you can see the "where used list" and to get the internal table column names you can use a function module called GET_COMPONENT_LIST .

CALL FUNCTION 'GET_COMPONENT_LIST'

EXPORTING

PROGRAM = sy-repid

FIELDNAME = 'WA_WBS'

TABLES

COMPONENTS = res1

.

'WA_WBS' - structure name to get column names

res1 - data res1 type table of rstrucinfo with header line.

Regards,

soumya

Read only

mahaboob_pathan
Contributor
0 Likes
787

Hi,

select that name of the internal table and follw this path

UTILITIES -> WHERE USED LIST

you will get one pop up and select program option there

it shows the programs in which it is used .

Read only

former_member810660
Participant
0 Likes
787

Thanks for your suggestions