Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8526

Re: Expand internal table at runtime

$
0
0

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 -

  1. Get the components(read: fields) from the data reference you have created earlier.
  2. Add the component, type LVC_T_STYL, to the table from (1).
  3. Get the RTTC instance of the table using the component table from (2).
  4. Create the data reference using the RTTC handle from (3).

 

So you can try this code snippet

  1. DATA dref_tab TYPE REF TO data.
  2. CREATE DATA dref_tab TYPE STANDARD TABLE OF ('SFLIGHT').
  3. ASSIGN dref_tab->* TO FIELD-SYMBOL(<tab>).
  4. * Get the fields from the data reference
  5. DATA(comp_tab) =
  6. CAST cl_abap_structdescr(
  7.      CAST cl_abap_tabledescr(
  8.           cl_abap_typedescr=>describe_by_data_ref( dref_tab )
  9.           )->get_table_line_type( )
  10.      )->get_components( ).
  11. * Add the field for the "Style" element
  12. DATA component TYPE abap_componentdescr.
  13. component-name = `STYLE`.
  14. component-type
  15. = CAST cl_abap_tabledescr(
  16.        cl_abap_typedescr=>describe_by_name( 'LVC_T_STYL' )
  17.        ).
  18. APPEND component TO comp_tab.
  19. TRY .
  20.     DATA(oref_rttc_tab) =
  21.     cl_abap_tabledescr=>get( cl_abap_structdescr=>get( comp_tab ) ).
  22.   CATCH ##no_handler
  23.         cx_sy_struct_creation
  24.         cx_sy_table_creation.
  25. ENDTRY.
  26. DATA dref_tab_alv TYPE REF TO data.
  27. CREATE DATA dref_tab_alv TYPE HANDLE oref_rttc_tab.
  28. UNASSIGN <tab>.
  29. ASSIGN dref_tab_alv->* TO <tab>.

BR,

Suhas

 

PS - Please excuse me i can't stop loving ABAP 740


Viewing all articles
Browse latest Browse all 8526

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>