Hello,
First-of-all a very unique name
Anyway the RTTS classes are very intuitive and you can think of creating the components of a runtime structure similar to creating a static structure.
The algorithm is as follows -
- Get the components(read: fields) from the data reference you have created earlier.
- Add the component, type LVC_T_STYL, to the table from (1).
- Get the RTTC instance of the table using the component table from (2).
- Create the data reference using the RTTC handle from (3).
So you can try this code snippet
- DATA dref_tab TYPE REF TO data.
- CREATE DATA dref_tab TYPE STANDARD TABLE OF ('SFLIGHT').
- ASSIGN dref_tab->* TO FIELD-SYMBOL(<tab>).
- * Get the fields from the data reference
- DATA(comp_tab) =
- CAST cl_abap_structdescr(
- CAST cl_abap_tabledescr(
- cl_abap_typedescr=>describe_by_data_ref( dref_tab )
- )->get_table_line_type( )
- )->get_components( ).
- * Add the field for the "Style" element
- DATA component TYPE abap_componentdescr.
- component-name = `STYLE`.
- component-type
- = CAST cl_abap_tabledescr(
- cl_abap_typedescr=>describe_by_name( 'LVC_T_STYL' )
- ).
- APPEND component TO comp_tab.
- TRY .
- DATA(oref_rttc_tab) =
- cl_abap_tabledescr=>get( cl_abap_structdescr=>get( comp_tab ) ).
- CATCH ##no_handler
- cx_sy_struct_creation
- cx_sy_table_creation.
- ENDTRY.
- DATA dref_tab_alv TYPE REF TO data.
- CREATE DATA dref_tab_alv TYPE HANDLE oref_rttc_tab.
- UNASSIGN <tab>.
- ASSIGN dref_tab_alv->* TO <tab>.
BR,
Suhas
PS - Please excuse me i can't stop loving ABAP 740