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

RTTS Class Hierarchy

Former Member
0 Likes
462

Hi,

I want to create an itab with making use of the RTTS Class Hierarchy. I have a parameter in my program that is the name of a database table. Now I want to create an itab with method cl_abap_tabledescr=>create. After this I want to use the parameter and the dynamically created itab in an open SQL statement.

Has anybody an example of the code to be used?

Regards,

Patrick

1 REPLY 1
Read only

Former Member
0 Likes
410

Solved.

With thanks to Ben Meijs!

  • Nu gaan we nog stapje verder en maken volledig dynamisch

  • een interne table van variabel type en variabele linetype

parameters: pa_ttype type abap_tablekind default 'S', "(S, H, O)

pa_type type char40 default 'T000'.

data: rf_line_type type ref to cl_abap_structdescr,

rf_table_type type ref to cl_abap_tabledescr.

data: dr_itab type ref to data.

field-symbols: <itab> type table,

<wa> type any.

rf_line_type ?= cl_abap_typedescr=>describe_by_name( pa_type ).

rf_table_type = cl_abap_tabledescr=>create(

p_line_type = rf_line_type

p_table_kind = pa_ttype

).

create data dr_itab type handle rf_table_type.

assign dr_itab->* to <itab> casting type handle rf_table_type.

select * from (pa_type) into table <itab>.

loop at <itab> assigning <wa>.

write: / <wa>.

endloop.