Hi,
You can use RTTI i,e run time type identification to identify the line type of the table and then loop at it to display the fields.
example code :
type-pools: abap.
*Declare the type of the internal table
types: beginofx_final,
matnrtypematnr,
werkstypewerks_d,
flagtypeclength 1,
valuetypeplength 10 decimals 2,
endofx_final.
data:
*The Internal table whose components are to found
i_datatypesortedtableofx_finalwithuniquekeymatnr,
*Table to hold the components
tab_returntypeabap_compdescr_tab,
*Work area for the component table
componentslikelineoftab_return.
*Call Perform to get the Int. Table Components
performget_int_table_fieldsusing i_data
changing tab_return.
*Display Components
loopattab_returnintocomponents.
write: / components-name, components-type_kind,
components-length,components-decimals.
endloop.
*&---------------------------------------------------------------------*
*& Form get_int_table_fields
*&---------------------------------------------------------------------*
* Get the Components of an internal table
*----------------------------------------------------------------------*
* -->T_DATA text
* -->T_RETURN text
*----------------------------------------------------------------------*
formget_int_table_fields using t_datatypeanytable
changingt_returntypeabap_compdescr_tab.
data:
oref_tabletypereftocl_abap_tabledescr,
oref_structypereftocl_abap_structdescr,
oref_errortypereftocx_root,
texttypestring.
*Get the description of data object type
try.
oref_table ?=
cl_abap_tabledescr=>describe_by_data(t_data).
catchcx_rootintooref_error.
text = oref_error->get_text().
write: / text.
exit.
endtry.
*Get the line type
try.
oref_struc ?= oref_table->get_table_line_type().
catchcx_rootintooref_error.
text = oref_error->get_text().
write: / text.
exit.
endtry.
appendlinesoforef_struc->componentstot_return.
endform. " GET_INT_TABLE_FIELDS
regards,
Ashish Rawat