<?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: Creating tables dynamically in loop in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/creating-tables-dynamically-in-loop/m-p/12738845#M2020943</link>
    <description>&lt;P&gt;Thanks Matthew&lt;/P&gt;</description>
    <pubDate>Wed, 18 Oct 2023 08:14:20 GMT</pubDate>
    <dc:creator>mohammadaamir_khan</dc:creator>
    <dc:date>2023-10-18T08:14:20Z</dc:date>
    <item>
      <title>Creating tables dynamically in loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/creating-tables-dynamically-in-loop/m-p/12738841#M2020939</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
  &lt;P&gt;I have an internal table ( say table_1) in which 1 field ( KOTABNR ) holds the table name.&lt;/P&gt;
  &lt;P&gt;I need to loop at table_1 and have to create as many internal tables as there are entries in the field KOTABNR.&lt;/P&gt;
  &lt;P&gt;I am not able to declare field symbol names dynamically so that I can identify which table is created against a particular entry in table_1.&lt;/P&gt;
  &lt;P&gt;Please help on the issue.&lt;/P&gt;
  &lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 15:18:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/creating-tables-dynamically-in-loop/m-p/12738841#M2020939</guid>
      <dc:creator>mohammadaamir_khan</dc:creator>
      <dc:date>2023-10-17T15:18:19Z</dc:date>
    </item>
    <item>
      <title>Re: Creating tables dynamically in loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/creating-tables-dynamically-in-loop/m-p/12738842#M2020940</link>
      <description>&lt;P&gt;The declaration of a field symbol is somewhat "dynamic":&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;FIELD-SYMBOLS &amp;lt;ITAB&amp;gt; TYPE ANY TABLE.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Each time you need to access one of the many internal tables, you do:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;ASSIGN dref_itab-&amp;gt;* TO &amp;lt;itab&amp;gt;.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Post your code if you're still not clear with the concept.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 17:36:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/creating-tables-dynamically-in-loop/m-p/12738842#M2020940</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2023-10-17T17:36:25Z</dc:date>
    </item>
    <item>
      <title>Re: Creating tables dynamically in loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/creating-tables-dynamically-in-loop/m-p/12738843#M2020941</link>
      <description>&lt;P&gt;I am adding code snippet. Table lt_kobog_temp  has a field KOTABNR which has values for condition tables like 901, 902.....and we have to prepare internal table dynamically like it_a901, it_902..so that after loop, i can read each table in sequence . &lt;/P&gt;&lt;P&gt;In the below code, only one internal table &amp;lt;f_itab&amp;gt; gets created. If somehow, I can declare field symbol name dynamically inside loop, then i can create many internal tables dynamically but right now, i am unable to achieve it.&lt;/P&gt;FIELD-SYMBOLS : &amp;lt;f_itab&amp;gt; TYPE ANY TABLE.&lt;BR /&gt;DATA : w_dref       TYPE REF TO data,&lt;P&gt;             lv_table       TYPE tabname.&lt;/P&gt;* Now preparing the table&lt;BR /&gt;LOOP AT lt_kobog_temp INTO lwa_kobog.&lt;BR /&gt;&lt;BR /&gt;  CONCATENATE 'A' lwa_kobog-KOTABNR INTO lv_table.&lt;BR /&gt;  CREATE DATA w_dref TYPE TABLE OF (lv_table).&lt;BR /&gt;  ASSIGN w_dref-&amp;gt;* TO &amp;lt;f_itab&amp;gt;.&lt;BR /&gt;&lt;BR /&gt;  SELECT * INTO TABLE &amp;lt;f_itab&amp;gt;&lt;BR /&gt;  FROM (lv_table) FOR ALL ENTRIES IN lt_konaind&lt;BR /&gt;    WHERE knumh = lt_konaind-knumh.&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;&lt;CODE&gt;ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Oct 2023 22:03:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/creating-tables-dynamically-in-loop/m-p/12738843#M2020941</guid>
      <dc:creator>mohammadaamir_khan</dc:creator>
      <dc:date>2023-10-17T22:03:05Z</dc:date>
    </item>
    <item>
      <title>Re: Creating tables dynamically in loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/creating-tables-dynamically-in-loop/m-p/12738844#M2020942</link>
      <description>&lt;P&gt;Try something like&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TYPES: BEGIN OF ty_table,
         tabname TYPE tabname,
         contents TYPE REF TO DATA,
       END OF ty_table.
TYPES ty_tables TYPE HASHED TABLE OF ty_table.
DATA tables TYPE ty_tables.
LOOP AT kobog_temp INTO kobog.
  DATA(tablename) = 'A' &amp;amp;&amp;amp; kobog-kotabnr.
  INSERT VALUE #( tabname = tablename ) INTO TABLE tables
       ASSIGNING FIELD-SYMBOL(&amp;lt;table&amp;gt;).
  CREATE DATA &amp;lt;table&amp;gt;-contents TYPE TABLE OF (tablename).
  FIELD-SYMBOLS &amp;lt;contents&amp;gt; TYPE STANDARD TABLE.
  ASSIGN &amp;lt;table&amp;gt;-contents-&amp;gt;* to &amp;lt;contents&amp;gt;.
  SELECT * INTO TABLE &amp;lt;contents&amp;gt; FROM (tablename)
       FOR ALL ENTRIES IN konaind
       WHERE knumh = koonaind-knumh.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Then, when you need to read one of the tables, something like&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;FIELD-SYMBOLS &amp;lt;contents&amp;gt; TYPE STANDARD TABLE.
ASSIGN tables[ tabname = tablename ]-contents-&amp;gt; TO &amp;lt;contents&amp;gt;.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Oct 2023 07:30:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/creating-tables-dynamically-in-loop/m-p/12738844#M2020942</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2023-10-18T07:30:24Z</dc:date>
    </item>
    <item>
      <title>Re: Creating tables dynamically in loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/creating-tables-dynamically-in-loop/m-p/12738845#M2020943</link>
      <description>&lt;P&gt;Thanks Matthew&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2023 08:14:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/creating-tables-dynamically-in-loop/m-p/12738845#M2020943</guid>
      <dc:creator>mohammadaamir_khan</dc:creator>
      <dc:date>2023-10-18T08:14:20Z</dc:date>
    </item>
  </channel>
</rss>

