‎2006 Mar 22 4:41 PM
Hi,
I am using CL_ALV_TABLE_CREATE to create a dynamic internal table. Everything works fine, but there is one problem with it. How can i create a component in the internal table that is actually a REF TO a certain data type. i.e. later i would like to store a reference to some dataobj in this component of the internal table.
I cannot use cl_abap_*descr classes to create internal table because of some other reasons, otherwise it would have been easy to do it.
Any kind of help would be highly appreciated.
Thanks and best regards,
Ghufran
‎2006 Mar 22 5:11 PM
Ghufran,
I don't think this class will be able to handle the complex data type. It clearly can deal only with basic data types.
Let me know if you find a work around.
Regards,
Ravi
‎2006 Mar 22 5:20 PM
Hi Ghufran,
I do have an idea about the class <b>CL_ALV_TABLE_CREATE</b> , but i have writen an exmaple code to create a Dynamic Iternal table, please have a look, it may help you
&----
*& Report Z_DYNAMIC_INTERNALTABLE *
*& *
&----
*& *
*& *
&----
report z_dynamic_internaltable .
data: d_ref type ref to data,
d_ref2 type ref to data ,
i_alv_cat type table of lvc_s_fcat,
ls_alv_cat like line of i_alv_cat.
types tabname like dcobjdef-name .
parameter: p_tablen type tabname.
data: begin of itab occurs 0.
include structure dntab.
data: end of itab.
field-symbols : <f_fs> type table,
<f_fs1> type table,
<f_fs2> type any,
<f_fs3> type table,
<f_fs4> type any.
refresh itab.
call function 'NAMETAB_GET'
exporting
langu = sy-langu
tabname = p_tablen
tables
nametab = itab
exceptions
no_texts_found = 1.
loop at itab .
ls_alv_cat-fieldname = itab-fieldname.
ls_alv_cat-ref_table = p_tablen.
ls_alv_cat-ref_field = itab-fieldname.
append ls_alv_cat to i_alv_cat.
endloop.
internal table build
call method cl_alv_table_create=>create_dynamic_table
exporting it_fieldcatalog = i_alv_cat
importing ep_table = d_ref .
assign d_ref->* to <f_fs>.
select * from (p_tablen) into corresponding fields of table <f_fs>.
loop at <f_fs> assigning <f_fs2>.
assign itab-fieldname to <f_fs4>.
loop at itab.
write: / <f_fs4>.
endloop.
endloop.
Thanks
Sudheer