<?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: ABAP dynamic tables add fields in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-dynamic-tables-add-fields/m-p/1009335#M78508</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;These weblogs also should help you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/people/subramanian.venkateswaran2/blog/2004/11/19/dynamic-internal-table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/people/ravikumar.allampallam/blog/2005/05/31/expand-the-list-of-columns-in-a-report-dynamically&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 05 Jul 2005 05:11:07 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2005-07-05T05:11:07Z</dc:date>
    <item>
      <title>ABAP dynamic tables add fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-dynamic-tables-add-fields/m-p/1009333#M78506</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, i have to extend a dynamic table like this:&lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS: &amp;lt;g_data&amp;gt; TYPE table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have to build a custom structure with all the fields&lt;/P&gt;&lt;P&gt;of g_data plus some other fixed fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In other words if g_data looks like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AUFNR POSNR&lt;/P&gt;&lt;P&gt;100   10&lt;/P&gt;&lt;P&gt;200   20&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My structure must be:&lt;/P&gt;&lt;P&gt;AUFNR POSNR F1  F2&lt;/P&gt;&lt;P&gt;100   10    23  21&lt;/P&gt;&lt;P&gt;200   20    234 32&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is anybody here who haves some ideas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Jul 2005 13:03:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-dynamic-tables-add-fields/m-p/1009333#M78506</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-07-04T13:03:16Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP dynamic tables add fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-dynamic-tables-add-fields/m-p/1009334#M78507</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is a sample program of how to build a dynamic internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

report zrich_0003
       no standard page heading.

type-pools: slis.

field-symbols: &amp;lt;dyn_table&amp;gt; type standard table,
               &amp;lt;dyn_wa&amp;gt;.

data: alv_fldcat type slis_t_fieldcat_alv,
      it_fldcat type lvc_t_fcat.


selection-screen begin of block b1 with frame title text-001.
parameters: p_check type c.
selection-screen end of block b1.

start-of-selection.

  perform build_dyn_itab.
  perform build_report.

  loop at &amp;lt;dyn_table&amp;gt; into &amp;lt;dyn_wa&amp;gt;.
    write:/ &amp;lt;dyn_wa&amp;gt;.
  endloop.


************************************************************************
*  Build_dyn_itab
************************************************************************
form build_dyn_itab.

  data: index(3) type c.

  data: new_table type ref to data,
        new_line  type ref to data,
        wa_it_fldcat type lvc_s_fcat.

  clear wa_it_fldcat.
  wa_it_fldcat-fieldname  = 'AUFNR'.
  wa_it_fldcat-datatype = 'CHAR'.
  wa_it_fldcat-intlen = 12.
  append wa_it_fldcat to it_fldcat .

  clear wa_it_fldcat.
  wa_it_fldcat-fieldname  = 'POSNR'.
  wa_it_fldcat-datatype = 'CHAR'.
  wa_it_fldcat-intlen = 6.
  append wa_it_fldcat to it_fldcat .

* Create fields
  clear index.
  do 2 times.
    index = sy-index.
    clear wa_it_fldcat.
    concatenate 'Field' index into
             wa_it_fldcat-fieldname .
    condense  wa_it_fldcat-fieldname no-gaps.
    wa_it_fldcat-datatype = 'CHAR'.
    wa_it_fldcat-intlen = 5.
    append wa_it_fldcat to it_fldcat .
  enddo.

* 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;.

endform.

*********************************************************************
*      Form  build_report
*********************************************************************
form build_report.

  data: fieldname(20) type c.
  data: fieldvalue(5) type c.
  data: index(3) type c.
  field-symbols: &amp;lt;fs1&amp;gt;.


  assign component  'AUFNR'  of structure &amp;lt;dyn_wa&amp;gt; to &amp;lt;fs1&amp;gt;.
  &amp;lt;fs1&amp;gt; =  '123456789'.

  assign component  'POSNR'  of structure &amp;lt;dyn_wa&amp;gt; to &amp;lt;fs1&amp;gt;.
  &amp;lt;fs1&amp;gt; =  '000001'.

  do 2 times.

    index = sy-index.

* Set up fieldname
    concatenate 'FIELD' index into
             fieldname .
    condense   fieldname  no-gaps.

* Set up fieldvalue
    concatenate 'FLD' index into
             fieldvalue.
    condense   fieldvalue no-gaps.

    assign component  fieldname  of structure &amp;lt;dyn_wa&amp;gt; to &amp;lt;fs1&amp;gt;.
    &amp;lt;fs1&amp;gt; =  fieldvalue.

  enddo.

* Append to the dynamic internal table
  append &amp;lt;dyn_wa&amp;gt; to &amp;lt;dyn_table&amp;gt;.

endform.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Rich Heilman&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have modified the sample to include your requirement&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Jul 2005 13:10:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-dynamic-tables-add-fields/m-p/1009334#M78507</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2005-07-04T13:10:38Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP dynamic tables add fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-dynamic-tables-add-fields/m-p/1009335#M78508</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;These weblogs also should help you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/people/subramanian.venkateswaran2/blog/2004/11/19/dynamic-internal-table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/people/ravikumar.allampallam/blog/2005/05/31/expand-the-list-of-columns-in-a-report-dynamically&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jul 2005 05:11:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-dynamic-tables-add-fields/m-p/1009335#M78508</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-07-05T05:11:07Z</dc:date>
    </item>
  </channel>
</rss>

