‎2006 Sep 11 11:13 PM
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
‎2006 Sep 12 7:49 AM
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.