Hello People,
I have a situation need your advice .
I need the list of all the fields from the table holded by field-symbol <F_TAB>.
Here iv_tab is input parameter of type data.
It is getting initiated dynamically means getting structure at run-time.
DATA: lo_strucdescr TYPE REF TO CL_ABAP_STRUCTDESCR.
FIELD-SYMBOLS: <f_tab> TYPE ANY,
<STR_COMP> TYPE ABAP_COMPDESCR.
ASSIGN iv_tab->* to <F_TAB>.
LO_STRUCDESCR ?= cl_abap_structdescr=>DESCRIBE_BY_DATA( <F_TAB> ). (Issue : Giving dump )
LOOP AT STRUC_DESC->COMPONENTS ASSIGNING <STR_COMP>.
* Build Fieldcatalog
LS_LVC_FIELDCATALOGUE-FIELDNAME = <STR_COMP>-NAME. ( Requirement : To get this Field name )
In below way it is working fine:
DATA: lo_strucdescr TYPE REF TO CL_ABAP_STRUCTDESCR.
FIELD-SYMBOLS: <f_tab> TYPE ANY,
<STR_COMP> TYPE ABAP_COMPDESCR.
CREATE DATA L_STRUCTURE TYPE (P_TABLE). Note : Here P_TABLE is holding table name.
ASSIGN L_STRUCTURE->* TO <F_TAB>.
LO_STRUCDESCR ?= cl_abap_structdescr=>DESCRIBE_BY_DATA( <F_TAB> ) (Working fine this way)
LOOP AT STRUC_DESC->COMPONENTS ASSIGNING <STR_COMP>.
* Build Fieldcatalog
LS_LVC_FIELDCATALOGUE-FIELDNAME = <STR_COMP>-NAME.
I cannot use the second way because i know the structure only at runtime.( Need in generic way )
Anybody have any idea how to solve this problem.