<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Dynamic Internal table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table/m-p/1940330#M388333</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT zzz_test1
             NO STANDARD PAGE HEADING
             MESSAGE-ID zcs_c2c_001.

type-pools : abap.

field-symbols: &amp;lt;dyn_table&amp;gt; type standard table,
               &amp;lt;dyn_wa&amp;gt;,
               &amp;lt;dyn_field&amp;gt;.

data: dy_table type ref to data,
      dy_line  type ref to data,
      xfc type lvc_s_fcat,
      ifc type lvc_t_fcat.

selection-screen begin of block b1 with frame.
parameters: p_table(30) type c default 'T001'.
selection-screen end of block b1.

start-of-selection.

  perform get_structure.
  perform create_dynamic_itab.
  perform get_data.
  perform write_out.

form get_structure.

data : idetails type abap_compdescr_tab,
       xdetails type abap_compdescr.

data : ref_table_des type ref to cl_abap_structdescr.

* Get the structure of the table.
  ref_table_des ?=
      cl_abap_typedescr=&amp;gt;describe_by_name( p_table ).
  idetails[] = ref_table_des-&amp;gt;components[].

  loop at idetails into xdetails.
    clear xfc.
    xfc-fieldname = xdetails-name .
    xfc-datatype = xdetails-type_kind.
    xfc-intlen = xdetails-length.
    xfc-decimals = xdetails-decimals.
    append xfc to ifc.
  endloop.

endform.

form create_dynamic_itab.

* Create dynamic internal table and assign to FS
  call method cl_alv_table_create=&amp;gt;create_dynamic_table
               exporting
                  it_fieldcatalog = ifc
               importing
                  ep_table        = dy_table.

  assign dy_table-&amp;gt;* to &amp;lt;dyn_table&amp;gt;.

* Create dynamic work area and assign to FS
  create data dy_line like line of &amp;lt;dyn_table&amp;gt;.
  assign dy_line-&amp;gt;* to &amp;lt;dyn_wa&amp;gt;.

endform.



form get_data.

* Select Data from table.
  select * into table &amp;lt;dyn_table&amp;gt;
             from (p_table).

endform.

form write_out.
* Write out data from table.
  loop at &amp;lt;dyn_table&amp;gt; into &amp;lt;dyn_wa&amp;gt;.
    do.
      assign component  sy-index
         of structure &amp;lt;dyn_wa&amp;gt; to &amp;lt;dyn_field&amp;gt;.
      if sy-subrc &amp;lt;&amp;gt; 0.
        exit.
      endif.
      if sy-index = 1.
        write:/ &amp;lt;dyn_field&amp;gt;.
      else.
        write: &amp;lt;dyn_field&amp;gt;.
      endif.
    enddo.
  endloop.
endform.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward if this helsp.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 26 Feb 2007 05:47:19 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-02-26T05:47:19Z</dc:date>
    <item>
      <title>Dynamic Internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table/m-p/1940329#M388332</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Friends,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone of you help me in creating and using the dynamic internal table in ABAP?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and Regards,&lt;/P&gt;&lt;P&gt;Venkatesh Babu E&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Feb 2007 05:45:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table/m-p/1940329#M388332</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-26T05:45:38Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table/m-p/1940330#M388333</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT zzz_test1
             NO STANDARD PAGE HEADING
             MESSAGE-ID zcs_c2c_001.

type-pools : abap.

field-symbols: &amp;lt;dyn_table&amp;gt; type standard table,
               &amp;lt;dyn_wa&amp;gt;,
               &amp;lt;dyn_field&amp;gt;.

data: dy_table type ref to data,
      dy_line  type ref to data,
      xfc type lvc_s_fcat,
      ifc type lvc_t_fcat.

selection-screen begin of block b1 with frame.
parameters: p_table(30) type c default 'T001'.
selection-screen end of block b1.

start-of-selection.

  perform get_structure.
  perform create_dynamic_itab.
  perform get_data.
  perform write_out.

form get_structure.

data : idetails type abap_compdescr_tab,
       xdetails type abap_compdescr.

data : ref_table_des type ref to cl_abap_structdescr.

* Get the structure of the table.
  ref_table_des ?=
      cl_abap_typedescr=&amp;gt;describe_by_name( p_table ).
  idetails[] = ref_table_des-&amp;gt;components[].

  loop at idetails into xdetails.
    clear xfc.
    xfc-fieldname = xdetails-name .
    xfc-datatype = xdetails-type_kind.
    xfc-intlen = xdetails-length.
    xfc-decimals = xdetails-decimals.
    append xfc to ifc.
  endloop.

endform.

form create_dynamic_itab.

* Create dynamic internal table and assign to FS
  call method cl_alv_table_create=&amp;gt;create_dynamic_table
               exporting
                  it_fieldcatalog = ifc
               importing
                  ep_table        = dy_table.

  assign dy_table-&amp;gt;* to &amp;lt;dyn_table&amp;gt;.

* Create dynamic work area and assign to FS
  create data dy_line like line of &amp;lt;dyn_table&amp;gt;.
  assign dy_line-&amp;gt;* to &amp;lt;dyn_wa&amp;gt;.

endform.



form get_data.

* Select Data from table.
  select * into table &amp;lt;dyn_table&amp;gt;
             from (p_table).

endform.

form write_out.
* Write out data from table.
  loop at &amp;lt;dyn_table&amp;gt; into &amp;lt;dyn_wa&amp;gt;.
    do.
      assign component  sy-index
         of structure &amp;lt;dyn_wa&amp;gt; to &amp;lt;dyn_field&amp;gt;.
      if sy-subrc &amp;lt;&amp;gt; 0.
        exit.
      endif.
      if sy-index = 1.
        write:/ &amp;lt;dyn_field&amp;gt;.
      else.
        write: &amp;lt;dyn_field&amp;gt;.
      endif.
    enddo.
  endloop.
endform.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward if this helsp.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Feb 2007 05:47:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table/m-p/1940330#M388333</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-26T05:47:19Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table/m-p/1940331#M388334</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please use this code.&lt;/P&gt;&lt;P&gt;for above WAS 6.20 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;report yes_tjung_sflight_test.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="3" type="ul"&gt;&lt;P&gt;Data Declaration&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: sflighttype type ref to cl_abap_structdescr,&lt;/P&gt;&lt;P&gt;      tabletype   type ref to cl_abap_tabledescr,&lt;/P&gt;&lt;P&gt;      comp_tab    type cl_abap_structdescr=&amp;gt;component_table,&lt;/P&gt;&lt;P&gt;      new_comp_tab like comp_tab,&lt;/P&gt;&lt;P&gt;      linetype type ref to cl_abap_structdescr,&lt;/P&gt;&lt;P&gt;      dref type ref to data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="3" type="ul"&gt;&lt;P&gt;Field Symbols&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;field-symbols: &amp;lt;wa_comp&amp;gt; like line of comp_tab.&lt;/P&gt;&lt;P&gt;field-symbols: &amp;lt;table&amp;gt; type any table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sflighttype ?= cl_abap_typedescr=&amp;gt;describe_by_name('SFLIGHT').&lt;/P&gt;&lt;P&gt;comp_tab = sflighttype-&amp;gt;get_components( ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at comp_tab assigning &amp;lt;wa_comp&amp;gt;.&lt;/P&gt;&lt;P&gt;case &amp;lt;wa_comp&amp;gt;-name.&lt;/P&gt;&lt;P&gt;when 'CARRID' or 'CONNID' or 'FLDATE' or 'PRICE' or 'CURRENCY'.&lt;/P&gt;&lt;P&gt;append &amp;lt;wa_comp&amp;gt; to new_comp_tab.&lt;/P&gt;&lt;P&gt;endcase.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;linetype = cl_abap_structdescr=&amp;gt;create( new_comp_tab ).&lt;/P&gt;&lt;P&gt;tabletype = cl_abap_tabledescr=&amp;gt;create(&lt;/P&gt;&lt;P&gt;p_line_type = linetype&lt;/P&gt;&lt;P&gt;p_table_kind = cl_abap_tabledescr=&amp;gt;tablekind_std ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;create data dref type handle tabletype.&lt;/P&gt;&lt;P&gt;assign dref-&amp;gt;* to &amp;lt;table&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from sflight into corresponding fields of table &amp;lt;table&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;field-symbols: &amp;lt;wa_data&amp;gt; type any.&lt;/P&gt;&lt;P&gt;field-symbols: &amp;lt;wa_field&amp;gt; type any.&lt;/P&gt;&lt;P&gt;loop at &amp;lt;table&amp;gt; assigning &amp;lt;wa_data&amp;gt;.&lt;/P&gt;&lt;P&gt;write: /.&lt;/P&gt;&lt;P&gt;loop at new_comp_tab assigning &amp;lt;wa_comp&amp;gt;.&lt;/P&gt;&lt;P&gt;assign component sy-tabix of structure &amp;lt;wa_data&amp;gt; to &amp;lt;wa_field&amp;gt;.&lt;/P&gt;&lt;P&gt;write: &amp;lt;wa_field&amp;gt;.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For was 6.20&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="3" type="ul"&gt;&lt;P&gt;Tables&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;DATA: LT_DATA type ref to DATA.&lt;/P&gt;&lt;P&gt;DATA: LT_FIELDCATALOG type LVC_T_FCAT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="3" type="ul"&gt;&lt;P&gt;Structure&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;DATA: LS_FIELDCATALOG type LVC_S_FCAT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="3" type="ul"&gt;&lt;P&gt;Data References&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;DATA: NEW_LINE type ref to data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="3" type="ul"&gt;&lt;P&gt;Field Symbols&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;FIELD-SYMBOLS: &amp;lt;FS_DATA&amp;gt; type ref to DATA,&lt;/P&gt;&lt;P&gt;               &amp;lt;FS_1&amp;gt; type any table,&lt;/P&gt;&lt;P&gt;               &amp;lt;FS_2&amp;gt;,&lt;/P&gt;&lt;P&gt;               &amp;lt;FS_3&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LS_FIELDCATALOG-FIELDNAME = 'MANDT'. &lt;/P&gt;&lt;P&gt;append LS_FIELDCATALOG to LT_FIELDCATALOG.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LS_FIELDCATALOG-FIELDNAME = 'CARRID'. "Fieldname&lt;/P&gt;&lt;P&gt;LS_FIELDCATALOG-INTTYPE = 'C'. "Internal Type C-&amp;gt; Character&lt;/P&gt;&lt;P&gt;append LS_FIELDCATALOG to LT_FIELDCATALOG.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LS_FIELDCATALOG-FIELDNAME = 'CONNID'.&lt;/P&gt;&lt;P&gt;LS_FIELDCATALOG-INTTYPE = 'N'.&lt;/P&gt;&lt;P&gt;append LS_FIELDCATALOG to LT_FIELDCATALOG.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LS_FIELDCATALOG-FIELDNAME = 'FLDATE'.&lt;/P&gt;&lt;P&gt;LS_FIELDCATALOG-INTTYPE = 'D'.&lt;/P&gt;&lt;P&gt;append LS_FIELDCATALOG to LT_FIELDCATALOG.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LS_FIELDCATALOG-FIELDNAME = 'PRICE'.&lt;/P&gt;&lt;P&gt;LS_FIELDCATALOG-INTTYPE = 'P'.&lt;/P&gt;&lt;P&gt;append LS_FIELDCATALOG to LT_FIELDCATALOG.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LS_FIELDCATALOG-FIELDNAME = 'CURRENCY'.&lt;/P&gt;&lt;P&gt;LS_FIELDCATALOG-INTTYPE = 'C'.&lt;/P&gt;&lt;P&gt;append LS_FIELDCATALOG to LT_FIELDCATALOG.&lt;/P&gt;&lt;P&gt;assign LT_DATA to &amp;lt;FS_DATA&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;call method cl_alv_table_create=create_dynamic_table&lt;/P&gt;&lt;P&gt;     exporting&lt;/P&gt;&lt;P&gt;       it_fieldcatalog = LT_FIELDCATALOG&lt;/P&gt;&lt;P&gt;     importing&lt;/P&gt;&lt;P&gt;       ep_table = FS_DATA&lt;/P&gt;&lt;P&gt;     exceptions&lt;/P&gt;&lt;P&gt;       generate_subpool_dir_full = 1&lt;/P&gt;&lt;P&gt;       others = 2&lt;/P&gt;&lt;P&gt;		.&lt;/P&gt;&lt;P&gt;if sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="3" type="ul"&gt;&lt;P&gt;So &amp;lt;FS_1&amp;gt; now points to our dynamic internal table.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;assign &amp;lt;FS_DATA&amp;gt;-&amp;gt;* to &amp;lt;FS_1&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="3" type="ul"&gt;&lt;P&gt;Next step is to create a work area for our dynamic internal table.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;create data NEW_LINE like line of &amp;lt;FS_1&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="3" type="ul"&gt;&lt;P&gt;A field-symbol to access that work area&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;assign NEW_LINE-&amp;gt;*  to &amp;lt;FS_2&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="3" type="ul"&gt;&lt;P&gt;And to put the data in the internal table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;select MANDT CARRID CONNID FLDATE PRICE CURRENCY&lt;/P&gt;&lt;P&gt;  from SFLIGHT&lt;/P&gt;&lt;P&gt;  into corresponding fields of table &amp;lt;FS_1&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="3" type="ul"&gt;&lt;P&gt;Access contents of internal table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;loop at &amp;lt;FS_1&amp;gt; assigning &amp;lt;FS_2&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;assign component 1 of structure &amp;lt;FS_2&amp;gt; to &amp;lt;FS_3&amp;gt;.&lt;/P&gt;&lt;P&gt;write: / &amp;lt;FS_3&amp;gt;.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: lv_tablename type string value 'SFLIGHT'.&lt;/P&gt;&lt;P&gt;data: lv_dref type ref to DATA.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CREATE DATA lv_dref type table of (lv_tablename).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS: &amp;lt;FS&amp;gt; TYPE STANDARD TABLE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ASSIGN lv_dref-&amp;gt;* TO &amp;lt;FS&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select *&lt;/P&gt;&lt;P&gt;  from sflight&lt;/P&gt;&lt;P&gt;  into table &amp;lt;FS&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please reward if useful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Feb 2007 05:50:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table/m-p/1940331#M388334</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-26T05:50:39Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table/m-p/1940332#M388335</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;/people/rich.heilman2/blog/2005/07/27/dynamic-internal-tables-and-structures--abap&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sap-img.com/ab030.htm" target="test_blank"&gt;http://www.sap-img.com/ab030.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;REPORT zus_sdn_dynamic_itab_create.&lt;/P&gt;&lt;P&gt;DATA:&lt;/P&gt;&lt;P&gt;gs_fcat TYPE lvc_s_fcat,&lt;/P&gt;&lt;P&gt;gt_fcat TYPE lvc_t_fcat,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;gdo_data TYPE REF TO data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS:&lt;/P&gt;&lt;P&gt;&amp;lt;gt_itab&amp;gt; TYPE table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;START-OF-SELECTION.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;i_structure_name = 'MARA'&lt;/P&gt;&lt;P&gt;CHANGING&lt;/P&gt;&lt;P&gt;ct_fieldcat = gt_fcat&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;inconsistent_interface = 1&lt;/P&gt;&lt;P&gt;program_error = 2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OTHERS = 3.&lt;/P&gt;&lt;P&gt;IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL FUNCTION&lt;/P&gt;&lt;P&gt;'LVC_FIELDCATALOG_MERGE'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;i_structure_name = 'KNB1'&lt;/P&gt;&lt;P&gt;CHANGING&lt;/P&gt;&lt;P&gt;ct_fieldcat = gt_fcat&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;inconsistent_interface = 1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;program_error = 2&lt;/P&gt;&lt;P&gt;OTHERS = 3.&lt;/P&gt;&lt;P&gt;IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DELETE gt_fcat WHERE NOT ( fieldname = 'MATNR' OR&lt;/P&gt;&lt;P&gt;fieldname = 'KUNNR' OR&lt;/P&gt;&lt;P&gt;fieldname =&lt;/P&gt;&lt;P&gt;'BUKRS' ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT gt_fcat INTO gs_fcat.&lt;/P&gt;&lt;P&gt;gs_fcat-col_pos = syst-tabix.&lt;/P&gt;&lt;P&gt;MODIFY gt_fcat FROM gs_fcat INDEX syst-tabix.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL METHOD cl_alv_table_create=&amp;gt;create_dynamic_table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;I_STYLE_TABLE =&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;it_fieldcatalog = gt_fcat&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;I_LENGTH_IN_BYTE =&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;IMPORTING&lt;/P&gt;&lt;P&gt;ep_table = gdo_data&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;E_STYLE_FNAME =&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;generate_subpool_dir_full = 1&lt;/P&gt;&lt;P&gt;OTHERS = 2.&lt;/P&gt;&lt;P&gt;IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ASSIGN gdo_data-&amp;gt;* TO &amp;lt;gt_itab&amp;gt;.&lt;/P&gt;&lt;P&gt;APPEND INITIAL LINE TO &amp;lt;gt_itab&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it_fieldcat_lvc = gt_fcat&lt;/P&gt;&lt;P&gt;TABLES&lt;/P&gt;&lt;P&gt;t_outtab = &amp;lt;gt_itab&amp;gt;&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;program_error = 1&lt;/P&gt;&lt;P&gt;OTHERS = 2.&lt;/P&gt;&lt;P&gt;IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;END-OF-SELECTION.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Feb 2007 06:00:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table/m-p/1940332#M388335</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-26T06:00:02Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table/m-p/1940333#M388336</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;give any table name at selection screen as per ur requirement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
parameter p_table type tabname.

field-symbols &amp;lt;tab&amp;gt; type table.
field-symbols &amp;lt;tab1&amp;gt; type any.


types: begin of itab,
      t_name type tabname,
      t_ref type ref to data,
      end of itab.

data itab1 type table of itab with non-unique key t_name.

perform fetch_data using p_table.
perform print_table using p_table.
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  fetch_data
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      --&amp;gt;P_P_TABLE  text
*----------------------------------------------------------------------*
FORM fetch_data  USING P_TABLE1 type tabname.

data itab2 type itab.
itab2-t_name = p_table1.

create data itab2-t_ref type table of (itab2-t_name) .

assign itab2-t_ref-&amp;gt;* to &amp;lt;tab&amp;gt;.

append itab2 to itab1.

select * from (p_table1) up to 25 rows into corresponding fields of table &amp;lt;tab&amp;gt;.

ENDFORM.                    " fetch_data
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  print_table
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      --&amp;gt;P_P_TABLE  text
*----------------------------------------------------------------------*
FORM print_table  USING P_TABLE1 type tabname.

DATA t_ref1 TYPE REF TO data.
DATA itab2 TYPE itab.

FIELD-SYMBOLS &amp;lt;field&amp;gt; TYPE ANY.

READ TABLE itab1 INTO itab2 WITH KEY t_name = p_table1.

ASSIGN itab2-t_ref-&amp;gt;* TO &amp;lt;tab&amp;gt;.

CREATE DATA t_ref1 LIKE LINE OF &amp;lt;tab&amp;gt;.

ASSIGN t_ref1-&amp;gt;* TO &amp;lt;tab1&amp;gt;.

DO.
*READ TABLE &amp;lt;tab&amp;gt; ASSIGNING &amp;lt;tab1&amp;gt; INDEX 1.
READ TABLE &amp;lt;tab&amp;gt; ASSIGNING &amp;lt;tab1&amp;gt; INDEX SY-INDEX.
*WRITE:/ p_table1.
NEW-LINE.
IF sy-subrc &amp;lt;&amp;gt; 0.
EXIT.
ENDIF.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE &amp;lt;tab1&amp;gt; TO &amp;lt;field&amp;gt;.
IF sy-subrc &amp;lt;&amp;gt; 0.
EXIT.
ENDIF.
WRITE: &amp;lt;field&amp;gt;,'    '.
ENDDO.
ENDDO.
ENDFORM.                    " print_table

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Feb 2007 06:01:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table/m-p/1940333#M388336</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-26T06:01:12Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table/m-p/1940334#M388337</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;  Here are the steps for creating dynamic internal tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Create your field catalog either manually or automatically using the function module, LVC_FIELDCATALOG_MERGE. Add more rows to the field catalog table (T_FIELDCAT) at run time. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Use the field catalog to create a table dynamically using the method below. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: T_OUTPUT TYPE REF TO DATA &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS: &amp;lt;T_OUTPUT&amp;gt; TYPE TABLE &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Call Method CL_ALV_TABLE_CREATE-&amp;gt;CREATE_DYNAMIC_TABLE &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Exporting &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IT_FIELDCATALOG = T_FIELDCAT &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Importing &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EP_TABLE = T_OUTPUT &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ASSIGN T_OUTPUT-&amp;gt;* TO &amp;lt;T_OUTPUT&amp;gt;. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now the field symbol &amp;lt;T_OUTPUT&amp;gt; is pointing to an output table of the structure that contains the fields which were determined at runtime. Now fill this table with the data and pass &amp;lt;T_OUTPUT&amp;gt; to the method SET_TABLE_FOR_FIRST_DISPLAY and the ALV grid should show the data properly. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;the content of itab will be fields of the new table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;loop at itab1 into wa1.&lt;/P&gt;&lt;P&gt;  Gs_FIELDCAT-TABNAME     = 'itab2'.&lt;/P&gt;&lt;P&gt;  GS_FIELDCAT-FIELDNAME = wa1-packid.&lt;/P&gt;&lt;P&gt;  GS_FIELDCAT-OUTPUTLEN = 2.&lt;/P&gt;&lt;P&gt;  GS_FIELDCAT-KEY         = space.&lt;/P&gt;&lt;P&gt;  GS_FIELDCAT-SELTEXT_L = wa1-packid.&lt;/P&gt;&lt;P&gt;  GS_FIELDCAT-COL_POS     =  1.&lt;/P&gt;&lt;P&gt;  GS_FIELDCAT-JUST        = 'L'.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;  APPEND GS_FIELDCAT TO GT_FIELDCAT.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;LOOP AT GT_FIELDCAT INTO GS_FIELDCAT.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;    MOVE-CORRESPONDING GS_FIELDCAT TO ls_fcat.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;    APPEND ls_fcat TO lt_fieldcat.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;CALL METHOD cl_alv_table_create=&amp;gt;create_dynamic_table&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;                     EXPORTING it_fieldcatalog = lt_fieldcat&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;                     IMPORTING ep_table = t_output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope this helps.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Kinshuk&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Feb 2007 06:06:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table/m-p/1940334#M388337</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-26T06:06:15Z</dc:date>
    </item>
  </channel>
</rss>

