<?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 Building dynamic internal tables in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/building-dynamic-internal-tables/m-p/918685#M58612</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all-&lt;/P&gt;&lt;P&gt;Need to know how I can dynamically create an internal table-&lt;/P&gt;&lt;P&gt;The data I have in one internal table is as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;VBELN   DATE   NUMBER&lt;/P&gt;&lt;P&gt;123      5/2/05     3&lt;/P&gt;&lt;P&gt;123      5/7/05     4&lt;/P&gt;&lt;P&gt;123      5/8/05     6&lt;/P&gt;&lt;P&gt;456      5/1/05     1&lt;/P&gt;&lt;P&gt;456      5/2/05     3&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;P&gt;From the data in this internal table&lt;/P&gt;&lt;P&gt;I want to create a new internal table that has the following entries:&lt;/P&gt;&lt;P&gt;Entry 1:&lt;/P&gt;&lt;P&gt;BEDID  DATE1   Num   DATE2    Num  DATE3     Num&lt;/P&gt;&lt;P&gt;123   5/2/05   3     5/7/05     4  5/8/05     6&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Entry 2:&lt;/P&gt;&lt;P&gt;BEDID  DATE1   Num    DATE2    Num  &lt;/P&gt;&lt;P&gt;456   5/1/05   1     5/2/05      3     &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;so basically building one entry per BEDID for all of the dates and number.&lt;/P&gt;&lt;P&gt;But the number of date entries per BEDID is dynamic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for ideas on how to accomplish this efficiently!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Jun 2005 18:58:39 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2005-06-10T18:58:39Z</dc:date>
    <item>
      <title>Building dynamic internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/building-dynamic-internal-tables/m-p/918685#M58612</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all-&lt;/P&gt;&lt;P&gt;Need to know how I can dynamically create an internal table-&lt;/P&gt;&lt;P&gt;The data I have in one internal table is as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;VBELN   DATE   NUMBER&lt;/P&gt;&lt;P&gt;123      5/2/05     3&lt;/P&gt;&lt;P&gt;123      5/7/05     4&lt;/P&gt;&lt;P&gt;123      5/8/05     6&lt;/P&gt;&lt;P&gt;456      5/1/05     1&lt;/P&gt;&lt;P&gt;456      5/2/05     3&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;P&gt;From the data in this internal table&lt;/P&gt;&lt;P&gt;I want to create a new internal table that has the following entries:&lt;/P&gt;&lt;P&gt;Entry 1:&lt;/P&gt;&lt;P&gt;BEDID  DATE1   Num   DATE2    Num  DATE3     Num&lt;/P&gt;&lt;P&gt;123   5/2/05   3     5/7/05     4  5/8/05     6&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Entry 2:&lt;/P&gt;&lt;P&gt;BEDID  DATE1   Num    DATE2    Num  &lt;/P&gt;&lt;P&gt;456   5/1/05   1     5/2/05      3     &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;so basically building one entry per BEDID for all of the dates and number.&lt;/P&gt;&lt;P&gt;But the number of date entries per BEDID is dynamic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for ideas on how to accomplish this efficiently!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Jun 2005 18:58:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/building-dynamic-internal-tables/m-p/918685#M58612</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-06-10T18:58:39Z</dc:date>
    </item>
    <item>
      <title>Re: Building dynamic internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/building-dynamic-internal-tables/m-p/918686#M58613</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi C K&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check out the class "&amp;lt;b&amp;gt;CL_ALV_TABLE_CREATE&amp;lt;/b&amp;gt;". Try its method called "&amp;lt;b&amp;gt;CREATE_DYNAMIC_TABLE&amp;lt;/b&amp;gt;". It is some easy just prepare a field catalog and call the method to give reference of dynamically created table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*--Serdar &amp;lt;a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d"&amp;gt;[ BC ]&amp;lt;/a&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Jun 2005 19:21:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/building-dynamic-internal-tables/m-p/918686#M58613</guid>
      <dc:creator>ssimsekler</dc:creator>
      <dc:date>2005-06-10T19:21:19Z</dc:date>
    </item>
    <item>
      <title>Re: Building dynamic internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/building-dynamic-internal-tables/m-p/918687#M58614</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Serder!  Please clarify where I would find this information?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Jun 2005 19:33:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/building-dynamic-internal-tables/m-p/918687#M58614</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-06-10T19:33:31Z</dc:date>
    </item>
    <item>
      <title>Re: Building dynamic internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/building-dynamic-internal-tables/m-p/918688#M58615</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is a quick and dirty sample program.&lt;/P&gt;&lt;P&gt;This should get you started.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

report zrich_0001.

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_flds(5) type c.
selection-screen end of block b1.

start-of-selection.

* build the dynamic internal table
  perform build_dyn_itab.

* write 5 records to the alv grid
  do 5 times.
    perform build_report.
  enddo.

* call the alv grid.
  perform call_alv.


************************************************************************
*  Build_dyn_itab
************************************************************************
form build_dyn_itab.

  data: new_table type ref to data,
        new_line  type ref to data,
        wa_it_fldcat type lvc_s_fcat.

* Create fields .
  do p_flds times.
    clear wa_it_fldcat.
    wa_it_fldcat-fieldname = sy-index.
    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;.

  do p_flds times.

    index = sy-index.

* Set up fieldvalue
    concatenate 'FLD' index into
             fieldvalue.
    condense   fieldvalue no-gaps.

    assign component  index  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.

************************************************************************
*  CALL_ALV
************************************************************************
form call_alv.

  data: wa_cat like line of alv_fldcat.

  do p_flds times.
    clear wa_cat.
    wa_cat-fieldname = sy-index.
    wa_cat-seltext_s = sy-index.
    wa_cat-outputlen = '5'.
    append wa_cat to alv_fldcat.
  enddo.


* Call ABAP List Viewer (ALV)
  call function 'REUSE_ALV_GRID_DISPLAY'
       exporting
            it_fieldcat = alv_fldcat
       tables
            t_outtab    = &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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Jun 2005 19:40:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/building-dynamic-internal-tables/m-p/918688#M58615</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2005-06-10T19:40:53Z</dc:date>
    </item>
    <item>
      <title>Re: Building dynamic internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/building-dynamic-internal-tables/m-p/918689#M58616</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Jun 2005 19:49:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/building-dynamic-internal-tables/m-p/918689#M58616</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-06-10T19:49:26Z</dc:date>
    </item>
  </channel>
</rss>

