Skip to Content
0
Former Member
Apr 07, 2009 at 10:13 AM

CREATE DATA dref

157 Views

Hi All,

I need to create internal table dynamically, and below is the sample code:

      DATA: tab_fieldcat  TYPE lvc_t_fcat.

      CREATE DATA dref_table TYPE (tabname).
      ASSIGN dref_table->* TO <wa>.

     structref ?= cl_abap_typedescr=>describe_by_data( <wa> ).    

      LOOP AT structref ->components ASSIGNING <wa_component>.
        IF sy_tabix < 10.
          wa_field-fieldname     = <wa_component>-name.
          wa_field-ref_table     = g_table.
          wa_field-ref_field     = <wa_component>-name.
          APPEND wa_field TO tab_fieldcat.
        ENDIF.
      ENDLOOP.

      CREATE DATA eptable LIKE tab_fieldcat.    <----------- PROBLEM !!!
      ASSIGN eptable->* TO <itab>

Problem face at the last statement CREATE DATA, where <itab> is containing field components ROW_POS, COL_POS, FIELDNAME, TABNAME, etc etc that those are fields coming from structure lvc_t_fcat.

But i want dynamic table created according to fields that i filtered during LOOP~ENDLOOP.

Please comment how i can achieve that.

FYI, i can't use method cl_alv_table_create=>create_dynamic_table since i've read the disadvantage abt it from internet.