<?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: Dynamically create Internal Table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-create-internal-table/m-p/4927674#M1149611</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sure, its possible. HEre is an example.  And you will find thousands more, when you search this forum.  &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;report zrich_0002.

type-pools: slis.

field-symbols: &amp;lt;dyn_table&amp;gt; type standard table,
               &amp;lt;dyn_wa&amp;gt;,
               &amp;lt;dyn_field&amp;gt;.

data: alv_fldcat type slis_t_fieldcat_alv,
      it_fldcat type lvc_t_fcat.

type-pools : abap.

data : it_details type abap_compdescr_tab,
       wa_details type abap_compdescr.

data : ref_descr type ref to cl_abap_structdescr.

data: new_table type ref to data,
      new_line  type ref to data,
      wa_it_fldcat type lvc_s_fcat.

selection-screen begin of block b1 with frame title text .
parameters: p_table(30) type c.
selection-screen end of block b1.


* Get the structure of the table.
ref_descr ?= cl_abap_typedescr=&amp;gt;describe_by_name( p_table ).
it_details[] = ref_descr-&amp;gt;components[].

loop at it_details into wa_details.
  clear wa_it_fldcat.
  wa_it_fldcat-fieldname = wa_details-name .
  wa_it_fldcat-datatype = wa_details-type_kind.
  wa_it_fldcat-inttype = wa_details-type_kind.
  wa_it_fldcat-intlen = wa_details-length.
  wa_it_fldcat-decimals = wa_details-decimals.
  append wa_it_fldcat to it_fldcat .
endloop.

* Create dynamic internal table and assign to FS
call method cl_alv_table_create=&amp;gt;create_dynamic_table
             exporting
                it_fieldcatalog = it_fldcat
             importing
                ep_table        = new_table.

assign new_table-&amp;gt;* to &amp;lt;dyn_table&amp;gt;.

* Create dynamic work area and assign to FS
create data new_line like line of &amp;lt;dyn_table&amp;gt;.
assign new_line-&amp;gt;* to &amp;lt;dyn_wa&amp;gt;.

* Select Data from table.
select * into corresponding fields of table &amp;lt;dyn_table&amp;gt;
           from (p_table).

* 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.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&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>Mon, 08 Dec 2008 17:17:31 GMT</pubDate>
    <dc:creator>RichHeilman</dc:creator>
    <dc:date>2008-12-08T17:17:31Z</dc:date>
    <item>
      <title>Dynamically create Internal Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-create-internal-table/m-p/4927673#M1149610</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 have a parameter in the program table name.&lt;/P&gt;&lt;P&gt;I want to create an Internal Table like the table name entered for this parameter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is this kind of dynamic creation of internal table from a variable possible.&lt;/P&gt;&lt;P&gt;If yes, can you guys please help me with it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;CD&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Dec 2008 17:10:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-create-internal-table/m-p/4927673#M1149610</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-08T17:10:33Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically create Internal Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-create-internal-table/m-p/4927674#M1149611</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sure, its possible. HEre is an example.  And you will find thousands more, when you search this forum.  &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;report zrich_0002.

type-pools: slis.

field-symbols: &amp;lt;dyn_table&amp;gt; type standard table,
               &amp;lt;dyn_wa&amp;gt;,
               &amp;lt;dyn_field&amp;gt;.

data: alv_fldcat type slis_t_fieldcat_alv,
      it_fldcat type lvc_t_fcat.

type-pools : abap.

data : it_details type abap_compdescr_tab,
       wa_details type abap_compdescr.

data : ref_descr type ref to cl_abap_structdescr.

data: new_table type ref to data,
      new_line  type ref to data,
      wa_it_fldcat type lvc_s_fcat.

selection-screen begin of block b1 with frame title text .
parameters: p_table(30) type c.
selection-screen end of block b1.


* Get the structure of the table.
ref_descr ?= cl_abap_typedescr=&amp;gt;describe_by_name( p_table ).
it_details[] = ref_descr-&amp;gt;components[].

loop at it_details into wa_details.
  clear wa_it_fldcat.
  wa_it_fldcat-fieldname = wa_details-name .
  wa_it_fldcat-datatype = wa_details-type_kind.
  wa_it_fldcat-inttype = wa_details-type_kind.
  wa_it_fldcat-intlen = wa_details-length.
  wa_it_fldcat-decimals = wa_details-decimals.
  append wa_it_fldcat to it_fldcat .
endloop.

* Create dynamic internal table and assign to FS
call method cl_alv_table_create=&amp;gt;create_dynamic_table
             exporting
                it_fieldcatalog = it_fldcat
             importing
                ep_table        = new_table.

assign new_table-&amp;gt;* to &amp;lt;dyn_table&amp;gt;.

* Create dynamic work area and assign to FS
create data new_line like line of &amp;lt;dyn_table&amp;gt;.
assign new_line-&amp;gt;* to &amp;lt;dyn_wa&amp;gt;.

* Select Data from table.
select * into corresponding fields of table &amp;lt;dyn_table&amp;gt;
           from (p_table).

* 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.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&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>Mon, 08 Dec 2008 17:17:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-create-internal-table/m-p/4927674#M1149611</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2008-12-08T17:17:31Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically create Internal Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-create-internal-table/m-p/4927675#M1149612</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Of course, if you are running on NetWeaver, you may do it like this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;report zrich_0002.

field-symbols: &amp;lt;dyn_table&amp;gt; type standard table,
               &amp;lt;dyn_wa&amp;gt;,
               &amp;lt;dyn_field&amp;gt;.

data: new_table type ref to data,
      new_line  type ref to data.

selection-screen begin of block b1 with frame title text .
parameters: p_table(30) type c.
selection-screen end of block b1.

create data new_table type table of (P_table).
assign new_table-&amp;gt;* to &amp;lt;dyn_table&amp;gt;.

* Create dynamic work area and assign to FS
create data new_line like line of &amp;lt;dyn_table&amp;gt;.
assign new_line-&amp;gt;* to &amp;lt;dyn_wa&amp;gt;.

* Select Data from table.
select * into corresponding fields of table &amp;lt;dyn_table&amp;gt;
           from (p_table).

* 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.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&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>Mon, 08 Dec 2008 17:25:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-create-internal-table/m-p/4927675#M1149612</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2008-12-08T17:25:02Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically create Internal Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-create-internal-table/m-p/4927676#M1149613</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;that one is helpful thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Dec 2008 17:26:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-create-internal-table/m-p/4927676#M1149613</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-08T17:26:00Z</dc:date>
    </item>
  </channel>
</rss>

