<?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: Create Internal Table Dynamically in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-internal-table-dynamically/m-p/3441132#M826417</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Solved Problem&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 28 Feb 2008 15:27:51 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-02-28T15:27:51Z</dc:date>
    <item>
      <title>Create Internal Table Dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-internal-table-dynamically/m-p/3441130#M826415</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need to create an internal table dynamically for the field names in another internal. Kindly help me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For Eg.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Internal Table IT_FNAME has following field names&lt;/P&gt;&lt;P&gt;FNAME&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="---------" /&gt;&lt;P&gt;WERKS&lt;/P&gt;&lt;P&gt;BUKRS&lt;/P&gt;&lt;P&gt;MATNR&lt;/P&gt;&lt;P&gt;MAKTX&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Internal table IT_OUT should be dynamically created with the above fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Feb 2008 23:55:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-internal-table-dynamically/m-p/3441130#M826415</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-21T23:55:00Z</dc:date>
    </item>
    <item>
      <title>Re: Create Internal Table Dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-internal-table-dynamically/m-p/3441131#M826416</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is a sample code to create an internal table dynamically.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
TYPE-POOLS:
  abap.
 
DATA:
  gr_structdescr    TYPE REF TO cl_abap_structdescr,
  gr_tabledescr     TYPE REF TO cl_abap_tabledescr,
  gt_components     TYPE abap_component_tab,
  gw_component      TYPE LINE OF abap_component_tab,
  gt_keys           TYPE abap_keydescr_tab,
  gw_key            TYPE LINE OF abap_keydescr_tab,
  gr_wa             TYPE REF TO data,
  gr_itab           TYPE REF TO data.
 
 
FIELD-SYMBOLS:
  &amp;lt;gw_wa&amp;gt;           TYPE ANY,
  &amp;lt;gt_itab&amp;gt;         TYPE ANY TABLE.
 
 
START-OF-SELECTION.
 
* determine components of structure -&amp;gt; GT_COMPONENTS
  MOVE 'COMP1' TO gw_component-name.
  gw_component-type ?= cl_abap_elemdescr=&amp;gt;get_string( ).
  INSERT gw_component INTO TABLE gt_components.
 
  MOVE 'COMP2' TO gw_component-name.
  gw_component-type ?= cl_abap_elemdescr=&amp;gt;get_i( ).
  INSERT gw_component INTO TABLE gt_components.
 
 
* get structure descriptor -&amp;gt; GR_STRUCTDESCR
  gr_structdescr ?= cl_abap_structdescr=&amp;gt;create( gt_components ).
 
 
* create work area of structure GR_STRUCTDESCR -&amp;gt; GR_WA
  CREATE DATA gr_wa TYPE HANDLE gr_structdescr.
 
  ASSIGN gr_wa-&amp;gt;* TO &amp;lt;gw_wa&amp;gt;.
 
 
* determine key components -&amp;gt; GT_KEYS
  MOVE 'COMP1' TO gw_key-name.
  INSERT gw_key INTO TABLE gt_keys.
 
 
* create descriptor for internal table -&amp;gt; GR_TABLEDESCR
  gr_tabledescr ?= cl_abap_tabledescr=&amp;gt;create( p_line_type  = gr_structdescr
                                               p_table_kind = cl_abap_tabledescr=&amp;gt;tablekind_hashed
                                               p_unique     = abap_true
                                               p_key        = gt_keys
                                               p_key_kind   = cl_abap_tabledescr=&amp;gt;keydefkind_user ).
 
 
* create internal table -&amp;gt; GR_ITAB
  CREATE DATA gr_itab TYPE HANDLE gr_tabledescr.
 
  ASSIGN gr_itab-&amp;gt;* TO &amp;lt;gt_itab&amp;gt;.
 
  sy-subrc = sy-subrc.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Sudhir Atluru&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Feb 2008 00:32:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-internal-table-dynamically/m-p/3441131#M826416</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-22T00:32:07Z</dc:date>
    </item>
    <item>
      <title>Re: Create Internal Table Dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-internal-table-dynamically/m-p/3441132#M826417</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Solved Problem&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Feb 2008 15:27:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-internal-table-dynamically/m-p/3441132#M826417</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-28T15:27:51Z</dc:date>
    </item>
  </channel>
</rss>

