<?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: really dynamic in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/really-dynamic/m-p/2126663#M446587</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&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;&lt;/P&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>Wed, 18 Apr 2007 07:54:18 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-04-18T07:54:18Z</dc:date>
    <item>
      <title>really dynamic</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/really-dynamic/m-p/2126662#M446586</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;there is quite a lot dynamic internal table blogs etc. but those instrcuctions does not help me to build up really dynamic internal table. Examples always point to some structure etc.&lt;/P&gt;&lt;P&gt;Case is: user gives date range in selection screen. Ex. 1.1.2007-20.1.2007.&lt;/P&gt;&lt;P&gt;Program should create internal table with fields for number of days in between those days.&lt;/P&gt;&lt;P&gt;So end result should be like this:&lt;/P&gt;&lt;P&gt;types: begin of lt_date_tab_dynamic_range,&lt;/P&gt;&lt;P&gt;          date_1   type syst-datum,&lt;/P&gt;&lt;P&gt;          date_2   type syst-datum,&lt;/P&gt;&lt;P&gt;          date_nn type syst-datum,&lt;/P&gt;&lt;P&gt;end of lt_date_range.&lt;/P&gt;&lt;P&gt;How this could do via abap?&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Apr 2007 07:47:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/really-dynamic/m-p/2126662#M446586</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-18T07:47:16Z</dc:date>
    </item>
    <item>
      <title>Re: really dynamic</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/really-dynamic/m-p/2126663#M446587</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&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;&lt;/P&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>Wed, 18 Apr 2007 07:54:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/really-dynamic/m-p/2126663#M446587</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-18T07:54:18Z</dc:date>
    </item>
    <item>
      <title>Re: really dynamic</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/really-dynamic/m-p/2126664#M446588</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check the link below. i know u must have already visited this , but this is a good ex where in a loop dyntable is created .&lt;/P&gt;&lt;P&gt;/people/alvaro.tejadagalindo/blog/2006/11/27/dynamic-alv-list-display&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Apr 2007 07:57:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/really-dynamic/m-p/2126664#M446588</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-18T07:57:04Z</dc:date>
    </item>
    <item>
      <title>Re: really dynamic</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/really-dynamic/m-p/2126665#M446589</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can do it by generation of code like below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form gen_cal_date.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; ld_source = 'form calculate_date.'.&lt;/P&gt;&lt;P&gt;  append ld_source to p_lt_lines.&lt;/P&gt;&lt;P&gt;  ld_source = '  DATA: BEGIN OF ls_date Occurs 0,'.&lt;/P&gt;&lt;P&gt;  append ld_source to p_lt_lines.&lt;/P&gt;&lt;P&gt;  loop at &amp;lt;itab&amp;gt; into &amp;lt;wa_itab&amp;gt;.&lt;/P&gt;&lt;P&gt;        ld_counter = ld_counter + 1.&lt;/P&gt;&lt;P&gt;        concatenate     &amp;lt;field&amp;gt;_ ld_counter'  type sy-datum,' into ld_source.&lt;/P&gt;&lt;P&gt;        append ld_source to p_lt_lines.&lt;/P&gt;&lt;P&gt;  endloop.&lt;/P&gt;&lt;P&gt;  ld_source = '       END OF ls_date.'.&lt;/P&gt;&lt;P&gt;  append ld_source to p_lt_lines.&lt;/P&gt;&lt;P&gt;  ld_source = 'endform.'.&lt;/P&gt;&lt;P&gt;  append ld_source to p_lt_lines.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope the above helps. If you need clarifications, do let me know.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Apr 2007 08:02:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/really-dynamic/m-p/2126665#M446589</guid>
      <dc:creator>Sathish</dc:creator>
      <dc:date>2007-04-18T08:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: really dynamic</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/really-dynamic/m-p/2126666#M446590</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Try this code.....................&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;types: begin of lt_date_tab_dynamic_range,&lt;/P&gt;&lt;P&gt;date_1 type syst-datum,&lt;/P&gt;&lt;P&gt;date_2 type syst-datum,&lt;/P&gt;&lt;P&gt;date_nn type i,&lt;/P&gt;&lt;P&gt;end of lt_date_tab_dynamic_range.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : itab type table of lt_date_tab_dynamic_range,&lt;/P&gt;&lt;P&gt;        wa type lt_date_tab_dynamic_range.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select-options : pa for sy-datum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: temp type i.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;start-of-selection.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;temp = pa-high - pa-low.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;wa-date_1  = pa-high.&lt;/P&gt;&lt;P&gt;wa-date_2  = pa-low.&lt;/P&gt;&lt;P&gt;wa-date_nn  = temp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;append wa to itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab into wa.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;write : wa-date_1, wa-date_2, wa-date_nn.&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;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Purshoth&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Apr 2007 08:10:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/really-dynamic/m-p/2126666#M446590</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-18T08:10:31Z</dc:date>
    </item>
    <item>
      <title>Re: really dynamic</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/really-dynamic/m-p/2126667#M446591</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;sorry Sudheer but your code not solve my problem..&lt;/P&gt;&lt;P&gt;"parameters: p_table(30) type c default 'T001' " this one makes it &amp;lt;b&amp;gt;not&amp;lt;/b&amp;gt; dynamic...&lt;/P&gt;&lt;P&gt;It is not dynamic if you give some structure etc to create table.&lt;/P&gt;&lt;P&gt;Sathis, yes i know that if i use generate program (which is only for internal use) i could do this but then hole program have to generate (because i could not import table type back from generated program).&lt;/P&gt;&lt;P&gt;And yes i have read those alv blogs but there is no solution for this or im stupid (which could be of course also true).&lt;/P&gt;&lt;P&gt;t. Reko&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Apr 2007 08:17:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/really-dynamic/m-p/2126667#M446591</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-18T08:17:26Z</dc:date>
    </item>
    <item>
      <title>Re: really dynamic</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/really-dynamic/m-p/2126668#M446592</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Reko,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I took the code from Rich Heilmans' blog.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Actually the table is created but i didn't populate it with data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
select-options : s_1 FOR SY-DATUM.


data : lv_i(3) type c,
       xfc type lvc_s_fcat,
      ifc type lvc_t_fcat.
data : lv_datum(2).
data: dy_table type ref to data.

lv_i = s_1-high - s_1-low.

do lv_i times.
lv_datum = lv_datum + 1 .
perform create_fieldcat using lv_datum.
enddo.

call method cl_alv_table_create=&amp;gt;create_dynamic_table
               exporting
                  it_fieldcatalog = ifc
               importing
                  ep_table        = dy_table.



*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  create_fieldcat
*&amp;amp;---------------------------------------------------------------------*
form create_fieldcat using pindex.
data : lv_day(7) .


concatenate 'DATE_' pindex into lv_day.
    xfc-fieldname =  lv_day.
    xfc-datatype  = 'DATS'.
    xfc-OUTPUTLEN   = '10'.

    append xfc to ifc.

endform.                    " create_fieldcat
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Apr 2007 08:28:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/really-dynamic/m-p/2126668#M446592</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-18T08:28:03Z</dc:date>
    </item>
    <item>
      <title>Re: really dynamic</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/really-dynamic/m-p/2126669#M446593</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Finally looks good! So i was stupid &lt;SPAN __jive_emoticon_name="sad"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Thanks Caglar!&lt;/P&gt;&lt;P&gt;reko&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Apr 2007 08:40:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/really-dynamic/m-p/2126669#M446593</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-18T08:40:54Z</dc:date>
    </item>
    <item>
      <title>Re: really dynamic</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/really-dynamic/m-p/2126670#M446594</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;and to put data into table:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;field-symbols: &amp;lt;lt_destination&amp;gt; type standard table.&lt;/P&gt;&lt;P&gt;field-symbols: &amp;lt;fs&amp;gt; type any,&lt;/P&gt;&lt;P&gt;                &amp;lt;ls_wa_to&amp;gt;,&lt;/P&gt;&lt;P&gt;                &amp;lt;fs_field&amp;gt; type any.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: ls_destination type ref to data.&lt;/P&gt;&lt;P&gt;data: lv_field type bdcdata-fnam.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;assign dy_table-&amp;gt;* to &amp;lt;lt_destination&amp;gt;.&lt;/P&gt;&lt;P&gt;create data ls_destination like line of &amp;lt;lt_destination&amp;gt;.&lt;/P&gt;&lt;P&gt;assign ls_destination-&amp;gt;* to &amp;lt;ls_wa_to&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; clear lv_datum.&lt;/P&gt;&lt;P&gt; do lv_i times.&lt;/P&gt;&lt;P&gt; lv_datum = lv_datum + 1 .&lt;/P&gt;&lt;P&gt; concatenate '&amp;lt;ls_wa_to&amp;gt;-' 'DATE_' lv_datum into lv_field.&lt;/P&gt;&lt;P&gt; assign (lv_field) to &amp;lt;fs_field&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;some data --&amp;gt;&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt; &amp;lt;fs_field&amp;gt; = sy-datum.&lt;/P&gt;&lt;P&gt; append &amp;lt;ls_wa_to&amp;gt; to &amp;lt;lt_destination&amp;gt;.&lt;/P&gt;&lt;P&gt; free &amp;lt;ls_wa_to&amp;gt;.&lt;/P&gt;&lt;P&gt; enddo.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Apr 2007 09:11:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/really-dynamic/m-p/2126670#M446594</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-18T09:11:39Z</dc:date>
    </item>
  </channel>
</rss>

