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 dynamically the internal table type

Former Member
0 Likes
1,260

Hello all,

is there a standard function to get the internal table type name.like if a internal table is based on sflight,by using the function i pass the internal table and get the type sflight.

regards

kaushik

1 ACCEPTED SOLUTION
Read only

Sm1tje
Active Contributor
0 Likes
1,134

for this we have the CL_ABAP_TYPEDESCR class, subclasses and all of their methods.

Coding should look something like this:


DATA: dref TYPE REF TO data.
FIELD-SYMBOLS: <table> TYPE STANDARD TABLE,
               <line>  TYPE ANY.

DATA: lr_reference TYPE REF TO cl_abap_typedescr.
DATA: lr_tab       TYPE REF TO cl_abap_tabledescr.
DATA: lr_data      TYPE REF TO cl_abap_datadescr.

PARAMETERS: pa_tab TYPE tabname DEFAULT 'BUT000'.

CREATE DATA dref TYPE STANDARD TABLE OF (pa_tab).
ASSIGN dref->* TO <table>.

SELECT * FROM but000 INTO TABLE <table>
         UP TO 10 ROWS.

CALL METHOD cl_abap_typedescr=>describe_by_data
  EXPORTING
    p_data      = <table>
  RECEIVING
    p_descr_ref = lr_reference.

lr_tab ?= lr_reference.
lr_data = lr_tab->get_table_line_type( ).


WRITE lr_data->absolute_name.

Edited by: Micky Oestreich on Jan 19, 2009 8:09 AM

Edited by: Micky Oestreich on Jan 19, 2009 8:44 AM

3 REPLIES 3
Read only

Sm1tje
Active Contributor
0 Likes
1,135

for this we have the CL_ABAP_TYPEDESCR class, subclasses and all of their methods.

Coding should look something like this:


DATA: dref TYPE REF TO data.
FIELD-SYMBOLS: <table> TYPE STANDARD TABLE,
               <line>  TYPE ANY.

DATA: lr_reference TYPE REF TO cl_abap_typedescr.
DATA: lr_tab       TYPE REF TO cl_abap_tabledescr.
DATA: lr_data      TYPE REF TO cl_abap_datadescr.

PARAMETERS: pa_tab TYPE tabname DEFAULT 'BUT000'.

CREATE DATA dref TYPE STANDARD TABLE OF (pa_tab).
ASSIGN dref->* TO <table>.

SELECT * FROM but000 INTO TABLE <table>
         UP TO 10 ROWS.

CALL METHOD cl_abap_typedescr=>describe_by_data
  EXPORTING
    p_data      = <table>
  RECEIVING
    p_descr_ref = lr_reference.

lr_tab ?= lr_reference.
lr_data = lr_tab->get_table_line_type( ).


WRITE lr_data->absolute_name.

Edited by: Micky Oestreich on Jan 19, 2009 8:09 AM

Edited by: Micky Oestreich on Jan 19, 2009 8:44 AM

Read only

faisalatsap
Active Contributor
0 Likes
1,134

Hi, Kaushik

Please have a look at the following Thread hope it will help you

Kind Regards,

Faisal

Read only

Former Member
0 Likes
1,134

Hi,

to get the name of the type of an internal table

use table DDO2L .

From this you can get properties of the respective tableand also tabclass field will give u the type of the table which u want.

hope this may help you out.