<?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: Internal tables - creating dynamically in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-tables-creating-dynamically/m-p/1936249#M387219</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Ashok,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the following , finally &amp;lt;fs_4&amp;gt; contains the heading and &amp;lt;fs_1&amp;gt; contains the data&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  DATA: new_fldcat TYPE lvc_t_fcat.&lt;/P&gt;&lt;P&gt;  DATA: new_fldcat_ln TYPE lvc_s_fcat..&lt;/P&gt;&lt;P&gt;  DATA:   lt_fieldcat_head TYPE lvc_t_fcat,&lt;/P&gt;&lt;P&gt;          lt_fcat TYPE lvc_s_fcat,&lt;/P&gt;&lt;P&gt;          lt_fcat_h TYPE lvc_s_fcat.&lt;/P&gt;&lt;P&gt;  FIELD-SYMBOLS: &amp;lt;fs_data&amp;gt; TYPE REF TO data,&lt;/P&gt;&lt;P&gt;                 &amp;lt;fs_1&amp;gt; TYPE ANY TABLE,&lt;/P&gt;&lt;P&gt;                 &amp;lt;fs_2&amp;gt;,&lt;/P&gt;&lt;P&gt;                 &amp;lt;fs_3&amp;gt;,&lt;/P&gt;&lt;P&gt;                 &amp;lt;fs&amp;gt;,&lt;/P&gt;&lt;P&gt;                 &amp;lt;fs_4&amp;gt; TYPE ANY TABLE,&lt;/P&gt;&lt;P&gt;                 &amp;lt;fs_5&amp;gt;.&lt;/P&gt;&lt;P&gt;  DATA: new_line TYPE REF TO data.&lt;/P&gt;&lt;P&gt;  DATA: lt_data TYPE REF TO data.&lt;/P&gt;&lt;P&gt;  DATA: dyn_lines TYPE i,&lt;/P&gt;&lt;P&gt;  DATA : count TYPE i.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CALL METHOD alvgrid_detail-&amp;gt;get_backend_fieldcatalog&lt;/P&gt;&lt;P&gt;    IMPORTING&lt;/P&gt;&lt;P&gt;      et_fieldcatalog = new_fldcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*this is for the fieldcatalog whatever u r selecting the fields only&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  LOOP AT new_fldcat INTO new_fldcat_ln WHERE no_out &amp;lt;&amp;gt; 'X'.&lt;/P&gt;&lt;P&gt;    CLEAR: lt_fcat,&lt;/P&gt;&lt;P&gt;           lt_fcat_h.&lt;/P&gt;&lt;P&gt;    MOVE new_fldcat_ln TO lt_fcat.&lt;/P&gt;&lt;P&gt;    APPEND lt_fcat TO lt_fieldcatalog.&lt;/P&gt;&lt;P&gt;    lt_fcat_h-fieldname = new_fldcat_ln-fieldname.&lt;/P&gt;&lt;P&gt;    lt_fcat_h-inttype = 'C'.&lt;/P&gt;&lt;P&gt;    lt_fcat_h-outputlen = STRLEN( new_fldcat_ln-scrtext_l ).&lt;/P&gt;&lt;P&gt;    APPEND lt_fcat_h TO lt_fieldcat_head.&lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;**dynamic table creation for data&lt;/P&gt;&lt;P&gt;  ASSIGN lt_data TO &amp;lt;fs_data&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&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           = lt_fieldcatalog&lt;/P&gt;&lt;P&gt;    IMPORTING&lt;/P&gt;&lt;P&gt;      ep_table                  = &amp;lt;fs_data&amp;gt;&lt;/P&gt;&lt;P&gt;    EXCEPTIONS&lt;/P&gt;&lt;P&gt;      generate_subpool_dir_full = 1&lt;/P&gt;&lt;P&gt;      OTHERS                    = 2.&lt;/P&gt;&lt;P&gt;  	&lt;/P&gt;&lt;P&gt;IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;  ASSIGN &amp;lt;fs_data&amp;gt;-&amp;gt;* TO &amp;lt;fs_1&amp;gt;.&lt;/P&gt;&lt;P&gt;  CREATE DATA new_line LIKE LINE OF &amp;lt;fs_1&amp;gt;.&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="3" type="ul"&gt;&lt;P&gt;A field-symbol to access that work area&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;  ASSIGN new_line-&amp;gt;*  TO &amp;lt;fs_2&amp;gt;.&lt;/P&gt;&lt;P&gt;***MOVE data&lt;/P&gt;&lt;P&gt;  DATA: wa_t_bom LIKE t_bom.&lt;/P&gt;&lt;P&gt;  LOOP AT t_bom_pdf INTO wa_t_bom .&lt;/P&gt;&lt;P&gt;    MOVE-CORRESPONDING   wa_t_bom TO &amp;lt;fs_2&amp;gt;.&lt;/P&gt;&lt;P&gt;    INSERT &amp;lt;fs_2&amp;gt; INTO TABLE &amp;lt;fs_1&amp;gt;.&lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;***CREATE DYNAMIC TABLE FOR HEADER TABLE&lt;/P&gt;&lt;P&gt;CLEAR: &amp;lt;fs_data&amp;gt;,&lt;/P&gt;&lt;P&gt;       new_line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DESCRIBE TABLE lt_fieldcat_head LINES dyn_lines.&lt;/P&gt;&lt;P&gt;&lt;/P&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           = lt_fieldcat_head&lt;/P&gt;&lt;P&gt;  IMPORTING&lt;/P&gt;&lt;P&gt;    ep_table                  = &amp;lt;fs_data&amp;gt;&lt;/P&gt;&lt;P&gt;  EXCEPTIONS&lt;/P&gt;&lt;P&gt;    generate_subpool_dir_full = 1&lt;/P&gt;&lt;P&gt;    OTHERS                    = 2.&lt;/P&gt;&lt;P&gt;	&lt;/P&gt;&lt;P&gt;IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;ASSIGN &amp;lt;fs_data&amp;gt;-&amp;gt;* TO &amp;lt;fs_4&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CREATE DATA new_line LIKE LINE OF &amp;lt;fs_4&amp;gt;.&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="3" type="ul"&gt;&lt;P&gt;A field-symbol to access that work area&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;ASSIGN new_line-&amp;gt;*  TO &amp;lt;fs_5&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;**ADD COLUMN HEADER&lt;/P&gt;&lt;P&gt;LOOP AT new_fldcat INTO new_fldcat_ln WHERE no_out &amp;lt;&amp;gt; 'X'.&lt;/P&gt;&lt;P&gt;  count = count + 1.&lt;/P&gt;&lt;P&gt;  ASSIGN COMPONENT count OF STRUCTURE &amp;lt;fs_5&amp;gt; TO &amp;lt;fs&amp;gt;.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; &amp;lt;fs&amp;gt; = new_fldcat_ln-scrtext_l.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  &amp;lt;fs&amp;gt; = new_fldcat_ln-seltext.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF NOT &amp;lt;fs_5&amp;gt; IS INITIAL.&lt;/P&gt;&lt;P&gt;  INSERT &amp;lt;fs_5&amp;gt; INTO TABLE &amp;lt;fs_4&amp;gt;.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Vasanth&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 12 Feb 2007 15:45:44 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-02-12T15:45:44Z</dc:date>
    <item>
      <title>Internal tables - creating dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-tables-creating-dynamically/m-p/1936247#M387217</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; Can Anyone give me information on how to create an internal table dynamically and when should we do this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, when do we need an internal table with header line and without header line??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ashok.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Feb 2007 15:24:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-tables-creating-dynamically/m-p/1936247#M387217</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-12T15:24:45Z</dc:date>
    </item>
    <item>
      <title>Re: Internal tables - creating dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-tables-creating-dynamically/m-p/1936248#M387218</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;Check&lt;/P&gt;&lt;P&gt;1. &lt;A class="jive_macro jive_macro_message" href="https://community.sap.com/" __jive_macro_name="message" modifiedtitle="true" __default_attr="797696"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. &lt;A class="jive_macro jive_macro_message" href="https://community.sap.com/" __jive_macro_name="message" modifiedtitle="true" __default_attr="2918725"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Santosh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Feb 2007 15:27:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-tables-creating-dynamically/m-p/1936248#M387218</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-12T15:27:00Z</dc:date>
    </item>
    <item>
      <title>Re: Internal tables - creating dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-tables-creating-dynamically/m-p/1936249#M387219</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Ashok,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the following , finally &amp;lt;fs_4&amp;gt; contains the heading and &amp;lt;fs_1&amp;gt; contains the data&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  DATA: new_fldcat TYPE lvc_t_fcat.&lt;/P&gt;&lt;P&gt;  DATA: new_fldcat_ln TYPE lvc_s_fcat..&lt;/P&gt;&lt;P&gt;  DATA:   lt_fieldcat_head TYPE lvc_t_fcat,&lt;/P&gt;&lt;P&gt;          lt_fcat TYPE lvc_s_fcat,&lt;/P&gt;&lt;P&gt;          lt_fcat_h TYPE lvc_s_fcat.&lt;/P&gt;&lt;P&gt;  FIELD-SYMBOLS: &amp;lt;fs_data&amp;gt; TYPE REF TO data,&lt;/P&gt;&lt;P&gt;                 &amp;lt;fs_1&amp;gt; TYPE ANY TABLE,&lt;/P&gt;&lt;P&gt;                 &amp;lt;fs_2&amp;gt;,&lt;/P&gt;&lt;P&gt;                 &amp;lt;fs_3&amp;gt;,&lt;/P&gt;&lt;P&gt;                 &amp;lt;fs&amp;gt;,&lt;/P&gt;&lt;P&gt;                 &amp;lt;fs_4&amp;gt; TYPE ANY TABLE,&lt;/P&gt;&lt;P&gt;                 &amp;lt;fs_5&amp;gt;.&lt;/P&gt;&lt;P&gt;  DATA: new_line TYPE REF TO data.&lt;/P&gt;&lt;P&gt;  DATA: lt_data TYPE REF TO data.&lt;/P&gt;&lt;P&gt;  DATA: dyn_lines TYPE i,&lt;/P&gt;&lt;P&gt;  DATA : count TYPE i.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CALL METHOD alvgrid_detail-&amp;gt;get_backend_fieldcatalog&lt;/P&gt;&lt;P&gt;    IMPORTING&lt;/P&gt;&lt;P&gt;      et_fieldcatalog = new_fldcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*this is for the fieldcatalog whatever u r selecting the fields only&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  LOOP AT new_fldcat INTO new_fldcat_ln WHERE no_out &amp;lt;&amp;gt; 'X'.&lt;/P&gt;&lt;P&gt;    CLEAR: lt_fcat,&lt;/P&gt;&lt;P&gt;           lt_fcat_h.&lt;/P&gt;&lt;P&gt;    MOVE new_fldcat_ln TO lt_fcat.&lt;/P&gt;&lt;P&gt;    APPEND lt_fcat TO lt_fieldcatalog.&lt;/P&gt;&lt;P&gt;    lt_fcat_h-fieldname = new_fldcat_ln-fieldname.&lt;/P&gt;&lt;P&gt;    lt_fcat_h-inttype = 'C'.&lt;/P&gt;&lt;P&gt;    lt_fcat_h-outputlen = STRLEN( new_fldcat_ln-scrtext_l ).&lt;/P&gt;&lt;P&gt;    APPEND lt_fcat_h TO lt_fieldcat_head.&lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;**dynamic table creation for data&lt;/P&gt;&lt;P&gt;  ASSIGN lt_data TO &amp;lt;fs_data&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&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           = lt_fieldcatalog&lt;/P&gt;&lt;P&gt;    IMPORTING&lt;/P&gt;&lt;P&gt;      ep_table                  = &amp;lt;fs_data&amp;gt;&lt;/P&gt;&lt;P&gt;    EXCEPTIONS&lt;/P&gt;&lt;P&gt;      generate_subpool_dir_full = 1&lt;/P&gt;&lt;P&gt;      OTHERS                    = 2.&lt;/P&gt;&lt;P&gt;  	&lt;/P&gt;&lt;P&gt;IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;  ASSIGN &amp;lt;fs_data&amp;gt;-&amp;gt;* TO &amp;lt;fs_1&amp;gt;.&lt;/P&gt;&lt;P&gt;  CREATE DATA new_line LIKE LINE OF &amp;lt;fs_1&amp;gt;.&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="3" type="ul"&gt;&lt;P&gt;A field-symbol to access that work area&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;  ASSIGN new_line-&amp;gt;*  TO &amp;lt;fs_2&amp;gt;.&lt;/P&gt;&lt;P&gt;***MOVE data&lt;/P&gt;&lt;P&gt;  DATA: wa_t_bom LIKE t_bom.&lt;/P&gt;&lt;P&gt;  LOOP AT t_bom_pdf INTO wa_t_bom .&lt;/P&gt;&lt;P&gt;    MOVE-CORRESPONDING   wa_t_bom TO &amp;lt;fs_2&amp;gt;.&lt;/P&gt;&lt;P&gt;    INSERT &amp;lt;fs_2&amp;gt; INTO TABLE &amp;lt;fs_1&amp;gt;.&lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;***CREATE DYNAMIC TABLE FOR HEADER TABLE&lt;/P&gt;&lt;P&gt;CLEAR: &amp;lt;fs_data&amp;gt;,&lt;/P&gt;&lt;P&gt;       new_line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DESCRIBE TABLE lt_fieldcat_head LINES dyn_lines.&lt;/P&gt;&lt;P&gt;&lt;/P&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           = lt_fieldcat_head&lt;/P&gt;&lt;P&gt;  IMPORTING&lt;/P&gt;&lt;P&gt;    ep_table                  = &amp;lt;fs_data&amp;gt;&lt;/P&gt;&lt;P&gt;  EXCEPTIONS&lt;/P&gt;&lt;P&gt;    generate_subpool_dir_full = 1&lt;/P&gt;&lt;P&gt;    OTHERS                    = 2.&lt;/P&gt;&lt;P&gt;	&lt;/P&gt;&lt;P&gt;IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;ASSIGN &amp;lt;fs_data&amp;gt;-&amp;gt;* TO &amp;lt;fs_4&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CREATE DATA new_line LIKE LINE OF &amp;lt;fs_4&amp;gt;.&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="3" type="ul"&gt;&lt;P&gt;A field-symbol to access that work area&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;ASSIGN new_line-&amp;gt;*  TO &amp;lt;fs_5&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;**ADD COLUMN HEADER&lt;/P&gt;&lt;P&gt;LOOP AT new_fldcat INTO new_fldcat_ln WHERE no_out &amp;lt;&amp;gt; 'X'.&lt;/P&gt;&lt;P&gt;  count = count + 1.&lt;/P&gt;&lt;P&gt;  ASSIGN COMPONENT count OF STRUCTURE &amp;lt;fs_5&amp;gt; TO &amp;lt;fs&amp;gt;.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; &amp;lt;fs&amp;gt; = new_fldcat_ln-scrtext_l.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  &amp;lt;fs&amp;gt; = new_fldcat_ln-seltext.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF NOT &amp;lt;fs_5&amp;gt; IS INITIAL.&lt;/P&gt;&lt;P&gt;  INSERT &amp;lt;fs_5&amp;gt; INTO TABLE &amp;lt;fs_4&amp;gt;.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Vasanth&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Feb 2007 15:45:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-tables-creating-dynamically/m-p/1936249#M387219</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-12T15:45:44Z</dc:date>
    </item>
    <item>
      <title>Re: Internal tables - creating dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-tables-creating-dynamically/m-p/1936250#M387220</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ashok Kumar,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Go through t e following sample Code for Dynamic Creation of Internal Tables&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;===================================== &lt;/P&gt;&lt;P&gt;REPORT zmaschl_create_data_dynamic . &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPE-POOLS: slis. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: it_fcat TYPE slis_t_fieldcat_alv, &lt;/P&gt;&lt;P&gt;is_fcat LIKE LINE OF it_fcat. &lt;/P&gt;&lt;P&gt;DATA: it_fieldcat TYPE lvc_t_fcat, &lt;/P&gt;&lt;P&gt;is_fieldcat LIKE LINE OF it_fieldcat. &lt;/P&gt;&lt;P&gt;DATA: new_table TYPE REF TO data. &lt;/P&gt;&lt;P&gt;DATA: new_line TYPE REF TO data. &lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS: &amp;lt;l_table&amp;gt; TYPE ANY TABLE, &lt;/P&gt;&lt;P&gt;&amp;lt;l_line&amp;gt; TYPE ANY, &lt;/P&gt;&lt;P&gt;&amp;lt;l_field&amp;gt; TYPE ANY. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Build fieldcat &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE' &lt;/P&gt;&lt;P&gt;EXPORTING &lt;/P&gt;&lt;P&gt;i_structure_name = 'SYST' &lt;/P&gt;&lt;P&gt;CHANGING &lt;/P&gt;&lt;P&gt;ct_fieldcat = it_fcat[]. &lt;/P&gt;&lt;P&gt;LOOP AT it_fcat INTO is_fcat WHERE NOT reptext_ddic IS initial. &lt;/P&gt;&lt;P&gt;MOVE-CORRESPONDING is_fcat TO is_fieldcat. &lt;/P&gt;&lt;P&gt;is_fieldcat-fieldname = is_fcat-fieldname. &lt;/P&gt;&lt;P&gt;is_fieldcat-ref_field = is_fcat-fieldname. &lt;/P&gt;&lt;P&gt;is_fieldcat-ref_table = is_fcat-ref_tabname. &lt;/P&gt;&lt;P&gt;APPEND is_fieldcat TO it_fieldcat. &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 a new Table &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_fieldcat &lt;/P&gt;&lt;P&gt;IMPORTING &lt;/P&gt;&lt;P&gt;ep_table = new_table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Create a new Line with the same structure of the table. &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;ASSIGN new_table-&amp;gt;* TO &amp;lt;l_table&amp;gt;. &lt;/P&gt;&lt;P&gt;CREATE DATA new_line LIKE LINE OF &amp;lt;l_table&amp;gt;. &lt;/P&gt;&lt;P&gt;ASSIGN new_line-&amp;gt;* TO &amp;lt;l_line&amp;gt;. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Test it... &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;DO 30 TIMES. &lt;/P&gt;&lt;P&gt;ASSIGN COMPONENT 'SUBRC' OF STRUCTURE &amp;lt;l_line&amp;gt; TO &amp;lt;l_field&amp;gt;. &lt;/P&gt;&lt;P&gt;&amp;lt;l_field&amp;gt; = sy-index. &lt;/P&gt;&lt;P&gt;INSERT &amp;lt;l_line&amp;gt; INTO TABLE &amp;lt;l_table&amp;gt;. &lt;/P&gt;&lt;P&gt;ENDDO. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT &amp;lt;l_table&amp;gt; ASSIGNING &amp;lt;l_line&amp;gt;. &lt;/P&gt;&lt;P&gt;ASSIGN COMPONENT 'SUBRC' OF STRUCTURE &amp;lt;l_line&amp;gt; TO &amp;lt;l_field&amp;gt;. &lt;/P&gt;&lt;P&gt;WRITE &amp;lt;l_field&amp;gt;. &lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Sreeni&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Feb 2007 16:26:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-tables-creating-dynamically/m-p/1936250#M387220</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-12T16:26:42Z</dc:date>
    </item>
    <item>
      <title>Re: Internal tables - creating dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-tables-creating-dynamically/m-p/1936251#M387221</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;in Present version, With header line is not the perfect one, it is not good for performance, even SAP itself it is saying that do not use with Header lines, so we need to use the Work Area's &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Simple Example For Dynamic Internal table Creation ..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;  type-pools : abap. 
  field-symbols: &amp;lt;dyn_table&amp;gt; type standard table, 
               &amp;lt;dyn_wa&amp;gt;, 
               &amp;lt;dyn_field&amp;gt;. 
  data: dy_table type ref to data, 
      dy_line  type ref to data, 
      xfc type lvc_s_fcat, 
      ifc type lvc_t_fcat. 
  selection-screen begin of block b1 with frame. 
parameters: p_table(30) type c default 'T001'. 
selection-screen end of block b1. 
  start-of-selection. 
    perform get_structure. 
  perform create_dynamic_itab.      **********Creates a dyanamic internal table********** 
  perform get_data. 
  perform write_out. 
  form get_structure. 
  data : idetails type abap_compdescr_tab, 
       xdetails type abap_compdescr. 
  data : ref_table_des type ref to cl_abap_structdescr. 
  * Get the structure of the table. 
  ref_table_des ?=  
      cl_abap_typedescr=&amp;gt;describe_by_name( p_table ). 
  idetails[] = ref_table_des-&amp;gt;components[]. 
    loop at idetails into xdetails. 
    clear xfc. 
    xfc-fieldname = xdetails-name . 
    xfc-datatype = xdetails-type_kind. 
    xfc-inttype = xdetails-type_kind. 
    xfc-intlen = xdetails-length. 
    xfc-decimals = xdetails-decimals. 
    append xfc to ifc. 
  endloop. 
  endform. 
  form create_dynamic_itab. 
  * Create dynamic internal table and assign to FS 
  call method cl_alv_table_create=&amp;gt;create_dynamic_table 
               exporting 
                  it_fieldcatalog = ifc 
               importing 
                  ep_table        = dy_table. 
    assign dy_table-&amp;gt;* to &amp;lt;dyn_table&amp;gt;. 
  * Create dynamic work area and assign to FS 
  create data dy_line like line of &amp;lt;dyn_table&amp;gt;. 
  assign dy_line-&amp;gt;* to &amp;lt;dyn_wa&amp;gt;. 
  endform. 
    
  form get_data. 
  * Select Data from table. 
  select * into table &amp;lt;dyn_table&amp;gt; 
             from (p_table). 
  endform. 
   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;Regards&lt;/P&gt;&lt;P&gt; Sudheer&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Feb 2007 17:42:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-tables-creating-dynamically/m-p/1936251#M387221</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-12T17:42:26Z</dc:date>
    </item>
  </channel>
</rss>

