‎2006 Jun 29 5:50 PM
I am trying to create a dynamic table based on a transparent table, but the component table returned by method <b>l_r_structype->get_components( )</b> does not contain the fields in an .include structure.
Does anyone know of a way around this?
l_r_structype ?= cl_abap_typedescr=>describe_by_name( p_tbl ).
l_t_comp_tab = l_r_structype->get_components( ).
LOOP AT l_t_comp_tab INTO l_s_comp_tab.
WRITE:/ l_s_comp_tab-name.
ENDLOOP.
LOGDPID
OBJVERS
VARIANT
SOURCE
TYP
LOGSYS
LOGDPID_N
FIRSTFLAG
UNAME
TIMESTAMP
OLTPSOURCE
OLTPTYP
GENERATED
CRT_PACKAGE
From FM DB_GET_TABLE_FIELDS (included fields are bold-faced):
LOGDPID
OBJVERS
VARIANT
SOURCE
TYP
LOGSYS
LOGDPID_N
FIRSTFLAG
UNAME
TIMESTAMP
<b>
OBJSTAT
CONTREL
CONTTIMESTMP
OWNER
BWAPPL
</b>
OLTPSOURCE
OLTPTYP
GENERATED
CRT_PACKAGE
‎2006 Jun 29 5:56 PM
Please see the example program. Does this pull all of the fields?
report zrich_0001 .
type-pools : abap.
data : it_details type abap_compdescr_tab,
wa_details type abap_compdescr.
data : ref_descr type ref to cl_abap_structdescr.
selection-screen begin of block b1 with frame title text .
parameters: p_table(30) type c.
selection-screen end of block b1.
* Get the structure of the table.
<b>ref_descr ?= cl_abap_typedescr=>describe_by_name( p_table ).
it_details[] = ref_descr->components[].</b>
loop at it_details into wa_details.
write:/ wa_details-name.
endloop.
Regards,
Rich Heilman
‎2006 Jun 29 5:56 PM
Please see the example program. Does this pull all of the fields?
report zrich_0001 .
type-pools : abap.
data : it_details type abap_compdescr_tab,
wa_details type abap_compdescr.
data : ref_descr type ref to cl_abap_structdescr.
selection-screen begin of block b1 with frame title text .
parameters: p_table(30) type c.
selection-screen end of block b1.
* Get the structure of the table.
<b>ref_descr ?= cl_abap_typedescr=>describe_by_name( p_table ).
it_details[] = ref_descr->components[].</b>
loop at it_details into wa_details.
write:/ wa_details-name.
endloop.
Regards,
Rich Heilman
‎2006 Jun 29 5:59 PM
It sure does. Thanks. I'll have to study it to see how it differs.
‎2006 Jun 29 6:02 PM
‎2006 Jun 29 6:08 PM
It is
l_r_structype TYPE REF TO cl_abap_structdescr,
Seems similar to your:
data : ref_descr type ref to cl_abap_structdescr.
statement.
‎2006 Jun 29 6:11 PM
‎2006 Jun 29 6:12 PM
My version gets the component table from a method call
l_t_comp_tab = l_r_structype->get_components( ).whereas yours references it directly.
it_details[] = ref_descr->components[].
I wonder if that is the difference.
‎2006 Jun 29 6:13 PM
‎2006 Jun 29 6:13 PM
‎2007 Apr 19 10:08 AM
This code will help you to create a workarea and display the contents of the transparent table you specify.
************************************
REPORT ZMART_DYNAMIC_TABLE .
PARAMETERS : tname(30).
DATA: dref TYPE REF TO DATA,tab type ref to data.
*data tname TYPE string.
field-symbols : <f> TYPE any,<fc> type any,<fcd>,<ft> type standard table.
*tname = TABNAME.
CREATE DATA dref TYPE (tname).
ASSIGN dref->* TO <f>.
create data tab like table of <f>.
assign tab->* to <ft>.
SELECT * INTO table <ft> from (tname).
LOOP AT <ft> INTO <f>.
do.
assign component sy-index
of structure <f> to <fcd>.
if sy-subrc <> 0.
exit.
endif.
if sy-index = 1.
write:/ <fcd>.
else.
write: <fcd>.
endif.
enddo.
ENDLOOP.
Please reward points if find informative.