<?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: Problem creating an internal table dynamically in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-creating-an-internal-table-dynamically/m-p/1218412#M135492</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check the comments section from my weblog mentioned above.  It seems that Rene has a viable solution, although I haven't tried it and I thought that I remember trying to use INTO CORRESPONDING FIELDS OF TABLE, but I think that it caused other problems.  Its forth a shot, give it a try.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 14 Mar 2006 03:15:23 GMT</pubDate>
    <dc:creator>RichHeilman</dc:creator>
    <dc:date>2006-03-14T03:15:23Z</dc:date>
    <item>
      <title>Problem creating an internal table dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-creating-an-internal-table-dynamically/m-p/1218408#M135488</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to create an internal table dynamically as i would be able to determine the structure of the table based on the user input.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've used the sample code from this forum ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT  ZRICH_0003       .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;type-pools: slis.&lt;/P&gt;&lt;P&gt;field-symbols: &amp;lt;dyn_table&amp;gt; type standard table,&lt;/P&gt;&lt;P&gt;               &amp;lt;dyn_wa&amp;gt;,&lt;/P&gt;&lt;P&gt;               &amp;lt;dyn_field&amp;gt;.&lt;/P&gt;&lt;P&gt;data: alv_fldcat type slis_t_fieldcat_alv,&lt;/P&gt;&lt;P&gt;               it_fldcat type lvc_t_fcat.&lt;/P&gt;&lt;P&gt;               type-pools : abap.&lt;/P&gt;&lt;P&gt;data : it_details type abap_compdescr_tab,&lt;/P&gt;&lt;P&gt;       wa_details type abap_compdescr.&lt;/P&gt;&lt;P&gt;data : ref_descr type ref to cl_abap_structdescr.&lt;/P&gt;&lt;P&gt;data: new_table type ref to data,&lt;/P&gt;&lt;P&gt;      new_line  type ref to data,&lt;/P&gt;&lt;P&gt;      wa_it_fldcat type lvc_s_fcat.&lt;/P&gt;&lt;P&gt;      selection-screen begin of block b1 with frame title text.&lt;/P&gt;&lt;P&gt;parameters: p_table(30) type c.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;selection-screen end of block b1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Get the structure of the table.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;ref_descr ?= cl_abap_typedescr=&amp;gt;describe_by_name( p_table ).&lt;/P&gt;&lt;P&gt;it_details[] = ref_descr-&amp;gt;components[].&lt;/P&gt;&lt;P&gt;loop at it_details into wa_details.&lt;/P&gt;&lt;P&gt;  clear wa_it_fldcat.&lt;/P&gt;&lt;P&gt;  wa_it_fldcat-fieldname = wa_details-name .&lt;/P&gt;&lt;P&gt;  wa_it_fldcat-datatype = wa_details-type_kind.&lt;/P&gt;&lt;P&gt;  wa_it_fldcat-inttype = wa_details-type_kind.&lt;/P&gt;&lt;P&gt;  wa_it_fldcat-intlen = wa_details-length.&lt;/P&gt;&lt;P&gt;  wa_it_fldcat-decimals = wa_details-decimals.&lt;/P&gt;&lt;P&gt;  append wa_it_fldcat to it_fldcat .&lt;/P&gt;&lt;P&gt;  endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Create dynamic internal table and assign to FS&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;call method cl_alv_table_create=&amp;gt;create_dynamic_table&lt;/P&gt;&lt;P&gt;            exporting&lt;/P&gt;&lt;P&gt;            it_fieldcatalog = it_fldcat&lt;/P&gt;&lt;P&gt;            importing&lt;/P&gt;&lt;P&gt;            ep_table        = new_table.&lt;/P&gt;&lt;P&gt;assign new_table-&amp;gt;* to &amp;lt;dyn_table&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Create dynamic work area and assign to FS&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;create data new_line like line of &amp;lt;dyn_table&amp;gt;.&lt;/P&gt;&lt;P&gt; assign new_line-&amp;gt;* to &amp;lt;dyn_wa&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;* Select Data from table.&lt;/P&gt;&lt;P&gt; select * into table &amp;lt;dyn_table&amp;gt;           from&lt;/P&gt;&lt;P&gt;(p_table).&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Write out data from table.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt; loop at &amp;lt;dyn_table&amp;gt; into &amp;lt;dyn_wa&amp;gt;.&lt;/P&gt;&lt;P&gt; do.&lt;/P&gt;&lt;P&gt; assign component  sy-index  of structure &amp;lt;dyn_wa&amp;gt; to &amp;lt;dyn_field&amp;gt;.&lt;/P&gt;&lt;P&gt; if sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt; exit.&lt;/P&gt;&lt;P&gt; endif.&lt;/P&gt;&lt;P&gt; if sy-index = 1.&lt;/P&gt;&lt;P&gt; write:/ &amp;lt;dyn_field&amp;gt;.&lt;/P&gt;&lt;P&gt; else.&lt;/P&gt;&lt;P&gt; write: &amp;lt;dyn_field&amp;gt;.&lt;/P&gt;&lt;P&gt; endif.&lt;/P&gt;&lt;P&gt; enddo.&lt;/P&gt;&lt;P&gt; endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm able to get the structure of the table that i want, but when i'm trying to select data from the table into this internal table..as highlighted in the sample code above..i'm getting a short dump...saying that ' the database table is 600 bytes wide but the internal table is only 576 bytes wide. &lt;/P&gt;&lt;P&gt;The internal table is declared as &lt;/P&gt;&lt;P&gt;field-symbols: &amp;lt;dyn_table&amp;gt; type standard table..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could anyone please tell me how to rectify this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Harsha.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Mar 2006 01:47:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-creating-an-internal-table-dynamically/m-p/1218408#M135488</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-03-14T01:47:55Z</dc:date>
    </item>
    <item>
      <title>Re: Problem creating an internal table dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-creating-an-internal-table-dynamically/m-p/1218409#M135489</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can check out examples explained in the attached threads -&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_message" href="https://community.sap.com/" __jive_macro_name="message" modifiedtitle="true" __default_attr="1284185"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_message" href="https://community.sap.com/" __jive_macro_name="message" modifiedtitle="true" __default_attr="1068619"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;have a look at Rich Heilman's blog on this subject:&lt;/P&gt;&lt;P&gt;/people/rich.heilman2/blog/2005/07/27/dynamic-internal-tables-and-structures--abap&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ashish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Mar 2006 02:12:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-creating-an-internal-table-dynamically/m-p/1218409#M135489</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-03-14T02:12:26Z</dc:date>
    </item>
    <item>
      <title>Re: Problem creating an internal table dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-creating-an-internal-table-dynamically/m-p/1218410#M135490</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes,  I have actually had the same problem with that example program.  It is not 100% effective.  I have not yet figured out what the exact problem is when dealing with certain tables.  I wrote that program using the T001 table as a test and it works good, but some tables do not work so well.  It may have something to do with the types of fields in the table.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What release are you on?  In newer releases, there is something called Run Time Type Services (RTTS) which may be a better way to go for you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Mar 2006 02:42:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-creating-an-internal-table-dynamically/m-p/1218410#M135490</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2006-03-14T02:42:14Z</dc:date>
    </item>
    <item>
      <title>Re: Problem creating an internal table dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-creating-an-internal-table-dynamically/m-p/1218411#M135491</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rich,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for replying.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm on 4.6C. Could you please describe any other way to read the table entries once the internal table is build.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Harsha&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Mar 2006 03:00:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-creating-an-internal-table-dynamically/m-p/1218411#M135491</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-03-14T03:00:12Z</dc:date>
    </item>
    <item>
      <title>Re: Problem creating an internal table dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-creating-an-internal-table-dynamically/m-p/1218412#M135492</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check the comments section from my weblog mentioned above.  It seems that Rene has a viable solution, although I haven't tried it and I thought that I remember trying to use INTO CORRESPONDING FIELDS OF TABLE, but I think that it caused other problems.  Its forth a shot, give it a try.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Mar 2006 03:15:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-creating-an-internal-table-dynamically/m-p/1218412#M135492</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2006-03-14T03:15:23Z</dc:date>
    </item>
    <item>
      <title>Re: Problem creating an internal table dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-creating-an-internal-table-dynamically/m-p/1218413#M135493</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  We had faced such a problem too.We had been missing out on one of the fields when we declared a structure to hold the values of the table.&lt;/P&gt;&lt;P&gt;Usually, every database table has a mandt field which by default is part of the primary key.&lt;/P&gt;&lt;P&gt;Are you sure you have included such a field in the structure or internal table you have created?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Smitha&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Mar 2006 03:47:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-creating-an-internal-table-dynamically/m-p/1218413#M135493</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-03-14T03:47:49Z</dc:date>
    </item>
    <item>
      <title>Re: Problem creating an internal table dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-creating-an-internal-table-dynamically/m-p/1218414#M135494</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Smitha,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm building the internal table by getting the structure using the method&lt;/P&gt;&lt;P&gt;cl_abap_typedescr=&amp;gt;describe_by_name( p_table ).&lt;/P&gt;&lt;P&gt;where p_table is the table name determined dynamically..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now using this structure, i'm building an internal table by calling the method &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;I've checked all the fields after the internal table has been created .. and it contains all the fields of the table that i'm supplying initially..&lt;/P&gt;&lt;P&gt;But when i read data into that internal table, it gives me that dump..I've described it in this post earlier.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any more suggestions would be very helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Harsha&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Mar 2006 04:05:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-creating-an-internal-table-dynamically/m-p/1218414#M135494</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-03-14T04:05:42Z</dc:date>
    </item>
  </channel>
</rss>

