<?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: Using variables for internal tables in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-variables-for-internal-tables/m-p/3584306#M862959</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do it like this...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: dataref TYPE REF TO data,
      descr_struct_ref TYPE REF TO cl_abap_structdescr,
      wa_fcat TYPE lvc_s_fcat,
      it_fieldcatalog TYPE lvc_t_fcat.

DATA: tab_name(20) TYPE c.

tab_name = 'SPFLI'.

FIELD-SYMBOLS: &amp;lt;fs&amp;gt; TYPE ANY,
               &amp;lt;component&amp;gt; TYPE abap_compdescr,
               &amp;lt;dyn_table&amp;gt; TYPE STANDARD TABLE.

CREATE DATA dataref TYPE (tab_name).

ASSIGN dataref-&amp;gt;* TO &amp;lt;fs&amp;gt;.

descr_struct_ref ?= cl_abap_typedescr=&amp;gt;describe_by_data( &amp;lt;fs&amp;gt; ).

LOOP AT descr_struct_ref-&amp;gt;components ASSIGNING &amp;lt;component&amp;gt;.
  wa_fcat-fieldname     = &amp;lt;component&amp;gt;-name.
  wa_fcat-ref_table     = tab_name.
  wa_fcat-ref_field     = &amp;lt;component&amp;gt;-name.
  APPEND wa_fcat TO it_fieldcatalog.
ENDLOOP.

CALL METHOD cl_alv_table_create=&amp;gt;create_dynamic_table
  EXPORTING
    it_fieldcatalog           = it_fieldcatalog
  IMPORTING
    ep_table                  = dataref
  EXCEPTIONS
    OTHERS                    = 1.

ASSIGN dataref-&amp;gt;* TO &amp;lt;dyn_table&amp;gt;.

select *
into corresponding fields of table &amp;lt;dyn_table&amp;gt;
from (tab_name).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Greetings,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Blag.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 19 Mar 2008 17:36:49 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-03-19T17:36:49Z</dc:date>
    <item>
      <title>Using variables for internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-variables-for-internal-tables/m-p/3584302#M862955</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to  show a lot of tables with ALV, i need to do something like this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: TABLE type tabname,&lt;/P&gt;&lt;P&gt;         TI        type tabname.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF OPT_ATV IS NOT INITIAL.&lt;/P&gt;&lt;P&gt;    TABLE = 'ZTSDHR005'.&lt;/P&gt;&lt;P&gt;    IT = 'ti_ZTSDHR005'.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF OPT_FORMATO IS NOT INITIAL.&lt;/P&gt;&lt;P&gt;    TABLE = 'ZTSDHR004'.&lt;/P&gt;&lt;P&gt;    IT = 'ti_ZTSDHR004'.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   select *&lt;/P&gt;&lt;P&gt;     into corresponding fields of table (IT)&lt;/P&gt;&lt;P&gt;     from (table)&lt;/P&gt;&lt;P&gt;     where erdat in fecha.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;then perform the report using ALV with IT.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;An error is displayed on select statement due to IT is not an internal table, i need that take the name of the internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;any ideas?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Mar 2008 17:16:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-variables-for-internal-tables/m-p/3584302#M862955</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-19T17:16:18Z</dc:date>
    </item>
    <item>
      <title>Re: Using variables for internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-variables-for-internal-tables/m-p/3584303#M862956</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I just saw the documentation, you can't assign the internal table name that way.&lt;/P&gt;&lt;P&gt;You need to make a dynamic table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Ramiro Escamilla on Mar 19, 2008 6:24 PM&lt;/P&gt;&lt;P&gt;Correcting error&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Mar 2008 17:19:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-variables-for-internal-tables/m-p/3584303#M862956</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-19T17:19:57Z</dc:date>
    </item>
    <item>
      <title>Re: Using variables for internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-variables-for-internal-tables/m-p/3584304#M862957</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;tks but is not working.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the error displayed is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Field "(TI)" is unknown. It is neither in one of the specified tables&lt;/P&gt;&lt;P&gt;nor defined by a "DATA" statement. "DATA" statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Mar 2008 17:30:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-variables-for-internal-tables/m-p/3584304#M862957</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-19T17:30:27Z</dc:date>
    </item>
    <item>
      <title>Re: Using variables for internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-variables-for-internal-tables/m-p/3584305#M862958</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, you can't do that, you need to create a dinamic table for each select you want to use.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use class CL_ALV_TABLE_CREATE and method CREATE_DYNAMIC_TABLE&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you know how to use ALV it should be easy to understand it&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Mar 2008 17:34:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-variables-for-internal-tables/m-p/3584305#M862958</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-19T17:34:51Z</dc:date>
    </item>
    <item>
      <title>Re: Using variables for internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-variables-for-internal-tables/m-p/3584306#M862959</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do it like this...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: dataref TYPE REF TO data,
      descr_struct_ref TYPE REF TO cl_abap_structdescr,
      wa_fcat TYPE lvc_s_fcat,
      it_fieldcatalog TYPE lvc_t_fcat.

DATA: tab_name(20) TYPE c.

tab_name = 'SPFLI'.

FIELD-SYMBOLS: &amp;lt;fs&amp;gt; TYPE ANY,
               &amp;lt;component&amp;gt; TYPE abap_compdescr,
               &amp;lt;dyn_table&amp;gt; TYPE STANDARD TABLE.

CREATE DATA dataref TYPE (tab_name).

ASSIGN dataref-&amp;gt;* TO &amp;lt;fs&amp;gt;.

descr_struct_ref ?= cl_abap_typedescr=&amp;gt;describe_by_data( &amp;lt;fs&amp;gt; ).

LOOP AT descr_struct_ref-&amp;gt;components ASSIGNING &amp;lt;component&amp;gt;.
  wa_fcat-fieldname     = &amp;lt;component&amp;gt;-name.
  wa_fcat-ref_table     = tab_name.
  wa_fcat-ref_field     = &amp;lt;component&amp;gt;-name.
  APPEND wa_fcat TO it_fieldcatalog.
ENDLOOP.

CALL METHOD cl_alv_table_create=&amp;gt;create_dynamic_table
  EXPORTING
    it_fieldcatalog           = it_fieldcatalog
  IMPORTING
    ep_table                  = dataref
  EXCEPTIONS
    OTHERS                    = 1.

ASSIGN dataref-&amp;gt;* TO &amp;lt;dyn_table&amp;gt;.

select *
into corresponding fields of table &amp;lt;dyn_table&amp;gt;
from (tab_name).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Greetings,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Blag.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Mar 2008 17:36:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-variables-for-internal-tables/m-p/3584306#M862959</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-19T17:36:49Z</dc:date>
    </item>
    <item>
      <title>Re: Using variables for internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-variables-for-internal-tables/m-p/3584307#M862960</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT create_dynamic_table.

PARAMETERS: p_tbl(80)  TYPE c DEFAULT 'TSTC'.

DATA: g_r_table              TYPE REF TO data,
      g_r_struct             TYPE REF TO data,
      g_r_structdescr        TYPE REF TO cl_abap_structdescr,
      g_r_tabledescr         TYPE REF TO cl_abap_tabledescr.

FIELD-SYMBOLS: &amp;lt;extract_table&amp;gt;      TYPE ANY TABLE.
FIELD-SYMBOLS: &amp;lt;extract_struct&amp;gt;     TYPE ANY.


START-OF-SELECTION.
  g_r_structdescr ?= cl_abap_typedescr=&amp;gt;describe_by_name( p_tbl ).
  g_r_tabledescr = cl_abap_tabledescr=&amp;gt;create(
                   p_line_type = g_r_structdescr
                   p_table_kind = cl_abap_tabledescr=&amp;gt;tablekind_std ).


  CREATE DATA g_r_table  TYPE HANDLE g_r_tabledescr.
  CREATE DATA g_r_struct TYPE HANDLE g_r_structdescr.
  ASSIGN g_r_table-&amp;gt;*  TO &amp;lt;extract_table&amp;gt;.
  ASSIGN g_r_struct-&amp;gt;* TO &amp;lt;extract_struct&amp;gt;.

  SELECT * FROM (p_tbl)
    INTO CORRESPONDING FIELDS OF TABLE &amp;lt;extract_table&amp;gt;.&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Mar 2008 18:06:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-variables-for-internal-tables/m-p/3584307#M862960</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-19T18:06:20Z</dc:date>
    </item>
  </channel>
</rss>

