<?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 Creation using selected fields from any db table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-creation-using-selected-fields-from-any-db-table/m-p/6007783#M1345455</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Uwe answer solved my Issue:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You may have a look at my Wiki sample:&lt;/P&gt;&lt;P&gt; [Creating Flat and Complex Internal Tables Dynamically using RTTI |https://wiki.sdn.sap.com/wiki/display/Snippets/Creating%20Flat%20and%20Complex%20Internal%20Tables%20Dynamically%20using%20RTTI]&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Uwe&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>Mon, 03 Aug 2009 22:22:56 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-08-03T22:22:56Z</dc:date>
    <item>
      <title>Dynamic Internal Table Creation using selected fields from any db table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-creation-using-selected-fields-from-any-db-table/m-p/6007779#M1345451</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to create a dynamic internal table which will have some fields from any one database table. For example I need to create a dynamic internal table it_ekko which will have only fields mandt eblen and aedat from database table ekko. I am able to achieve this using field catalogs and cl_alv_table_create=&amp;gt;create_dynamic_table but this class is obsolete and has a limitation of 36 tables in one loop.&lt;/P&gt;&lt;P&gt;       I want to achieve this using cl_abap_tabledescr=&amp;gt;create. I am having issues determining the wa_comp-type for the new internal table.  What should be assigned to wa_comp-type?  Any suggestions or input is highly appreciated.&lt;/P&gt;&lt;P&gt;Here is my code.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA:   
      linetype type ref to cl_abap_structdescr,
      tabletype type ref to cl_abap_tabledescr ,
      comp_tab type cl_abap_structdescr=&amp;gt;component_table,
      wa_comp like line of comp_tab,
      new_comp_tab like comp_tab,
      descr_table_ref_tmp TYPE REF TO cl_abap_tabledescr,
      descr_struct_ref_tmp TYPE REF TO cl_abap_structdescr,
      ls_components_tmp TYPE abap_compdescr_tab,
      wa_components_tmp like line of ls_components_tmp,
      table_ref TYPE REF TO DATA.
FIELD-SYMBOLS:
      &amp;lt;fs_tb&amp;gt; TYPE ANY TABLE.
CREATE DATA table_ref TYPE STANDARD TABLE OF (p_tabnam_low).
  ASSIGN table_ref-&amp;gt;* to &amp;lt;fs_tb&amp;gt;.
  descr_table_ref_tmp ?= cl_abap_typedescr=&amp;gt;describe_by_data( &amp;lt;fs_tb&amp;gt; ).
  descr_struct_ref_tmp ?= descr_table_ref_tmp-&amp;gt;get_table_line_type( ).
  ls_components_tmp = descr_struct_ref_tmp-&amp;gt;components.
 LOOP AT it_sel_field INTO wa_sel_field.
    READ TABLE ls_components_tmp INTO wa_components_tmp WITH KEY name = wa_sel_field.
    IF sy-subrc EQ 0.
      CLEAR: wa_fcat, wa_comp.
      wa_fcat-fieldname     = wa_components_tmp-name.
      wa_fcat-ref_table     = p_tabnam_low.
      wa_fcat-ref_field     = wa_components_tmp-name.
      APPEND wa_fcat TO it_fieldcatalog.
      wa_comp-name = wa_components_tmp-name.
      wa_comp-type ?= cl_abap_typedescr=&amp;gt;describe_by_data( wa_components_tmp-name ).   "??????? This doesnt work
      APPEND wa_comp TO new_comp_tab.
    ENDIF.
  ENDLOOP.
  linetype = cl_abap_structdescr=&amp;gt;create( new_comp_tab ).
  tabletype = cl_abap_tabledescr=&amp;gt;create(
  p_line_type = linetype
  p_table_kind = cl_abap_tabledescr=&amp;gt;tablekind_std ).
  create data dataref type handle tabletype.
  ASSIGN dataref-&amp;gt;* TO &amp;lt;row&amp;gt;.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Aug 2009 21:05:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-creation-using-selected-fields-from-any-db-table/m-p/6007779#M1345451</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-03T21:05:21Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Internal Table Creation using selected fields from any db table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-creation-using-selected-fields-from-any-db-table/m-p/6007780#M1345452</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Should be&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
wa_comp-name = wa_components_tmp-name.
wa_comp-type ?= cl_abap_elemdescr=&amp;gt;describe_by_data( wa_components_tmp-name ).   "class cl_abap_elemdescr
APPEND wa_comp TO new_comp_tab.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Marcin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Aug 2009 21:13:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-creation-using-selected-fields-from-any-db-table/m-p/6007780#M1345452</guid>
      <dc:creator>MarcinPciak</dc:creator>
      <dc:date>2009-08-03T21:13:19Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Internal Table Creation using selected fields from any db table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-creation-using-selected-fields-from-any-db-table/m-p/6007781#M1345453</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Marcin,&lt;/P&gt;&lt;P&gt;        I tried that option, but it still creates the new internal table with all fields as C(30) which i dont want.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Aug 2009 21:19:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-creation-using-selected-fields-from-any-db-table/m-p/6007781#M1345453</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-03T21:19:25Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Internal Table Creation using selected fields from any db table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-creation-using-selected-fields-from-any-db-table/m-p/6007782#M1345454</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Indeed strange issue. It returns C(30) type each time for each field. But I found some other solution. It works fine with method &lt;STRONG&gt;describe_by_name&lt;/STRONG&gt; of &lt;STRONG&gt;cl_abap_elemdescr&lt;/STRONG&gt; . Unfortunatelly it expects &lt;EM&gt;Data element&lt;/EM&gt; of field you want type of. So you can do:&lt;/P&gt;&lt;P&gt;- use fm &lt;STRONG&gt;CY_GET_FIELD&lt;/STRONG&gt; to get &lt;STRONG&gt;DFIES&lt;/STRONG&gt; structure for each component name&lt;/P&gt;&lt;P&gt;- call method &lt;STRONG&gt;describe by name&lt;/STRONG&gt; passing &lt;EM&gt;ROLLNAME&lt;/EM&gt; field of &lt;EM&gt;DFIES&lt;/EM&gt; struc. as name of component (data element) for typing&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then it will create your table with type refering to DDIC.&lt;/P&gt;&lt;P&gt;Though not state-of-the-art  approach but will work. Still there has to be some way using RTTS but can't find any right now.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Marcin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Aug 2009 22:20:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-creation-using-selected-fields-from-any-db-table/m-p/6007782#M1345454</guid>
      <dc:creator>MarcinPciak</dc:creator>
      <dc:date>2009-08-03T22:20:50Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Internal Table Creation using selected fields from any db table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-creation-using-selected-fields-from-any-db-table/m-p/6007783#M1345455</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Uwe answer solved my Issue:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You may have a look at my Wiki sample:&lt;/P&gt;&lt;P&gt; [Creating Flat and Complex Internal Tables Dynamically using RTTI |https://wiki.sdn.sap.com/wiki/display/Snippets/Creating%20Flat%20and%20Complex%20Internal%20Tables%20Dynamically%20using%20RTTI]&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Uwe&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>Mon, 03 Aug 2009 22:22:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-creation-using-selected-fields-from-any-db-table/m-p/6007783#M1345455</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-03T22:22:56Z</dc:date>
    </item>
  </channel>
</rss>

