<?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: dynamic table (rich prog) in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-table-rich-prog/m-p/1421941#M202434</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You want to have a dropdown of 10 default tables?&lt;/P&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>Tue, 27 Jun 2006 13:47:46 GMT</pubDate>
    <dc:creator>RichHeilman</dc:creator>
    <dc:date>2006-06-27T13:47:46Z</dc:date>
    <item>
      <title>dynamic table (rich prog)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-table-rich-prog/m-p/1421937#M202430</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;how can i use this prog to download tables with ';'between every field any idea?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;report z_dynamic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;type-pools : abap.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;field-symbols: &amp;lt;dyn_table&amp;gt; type standard table,&lt;/P&gt;&lt;P&gt;               &amp;lt;dyn_wa&amp;gt;,&lt;/P&gt;&lt;P&gt;               &amp;lt;dyn_field&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: dy_table type ref to data,&lt;/P&gt;&lt;P&gt;      dy_line  type ref to data,&lt;/P&gt;&lt;P&gt;      xfc type lvc_s_fcat,&lt;/P&gt;&lt;P&gt;      ifc type lvc_t_fcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;selection-screen begin of block b1 with frame.&lt;/P&gt;&lt;P&gt;parameters: p_table(30) type c default 'T001'.&lt;/P&gt;&lt;P&gt;selection-screen end of block b1.&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;  perform get_structure.&lt;/P&gt;&lt;P&gt;  perform create_dynamic_itab.&lt;/P&gt;&lt;P&gt;  perform get_data.&lt;/P&gt;&lt;P&gt;  perform write_out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form get_structure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : idetails type abap_compdescr_tab,&lt;/P&gt;&lt;P&gt;       xdetails type abap_compdescr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : ref_table_des type ref to cl_abap_structdescr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Get the structure of the table.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  ref_table_des ?=&lt;/P&gt;&lt;P&gt;      cl_abap_typedescr=&amp;gt;describe_by_name( p_table ).&lt;/P&gt;&lt;P&gt;  idetails[] = ref_table_des-&amp;gt;components[].&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  loop at idetails into xdetails.&lt;/P&gt;&lt;P&gt;    clear xfc.&lt;/P&gt;&lt;P&gt;    xfc-fieldname = xdetails-name .&lt;/P&gt;&lt;P&gt;    xfc-datatype = xdetails-type_kind.&lt;/P&gt;&lt;P&gt;    xfc-inttype = xdetails-type_kind.&lt;/P&gt;&lt;P&gt;    xfc-intlen = xdetails-length.&lt;/P&gt;&lt;P&gt;    xfc-decimals = xdetails-decimals.&lt;/P&gt;&lt;P&gt;    append xfc to ifc.&lt;/P&gt;&lt;P&gt;  endloop.&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;form create_dynamic_itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Create dynamic internal table and assign to FS&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 = ifc&lt;/P&gt;&lt;P&gt;               importing&lt;/P&gt;&lt;P&gt;                  ep_table        = dy_table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  assign dy_table-&amp;gt;* to &amp;lt;dyn_table&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Create dynamic work area and assign to FS&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  create data dy_line like line of &amp;lt;dyn_table&amp;gt;.&lt;/P&gt;&lt;P&gt;  assign dy_line-&amp;gt;* to &amp;lt;dyn_wa&amp;gt;.&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;&lt;/P&gt;&lt;P&gt;form get_data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Select Data from table.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  select * into table &amp;lt;dyn_table&amp;gt;&lt;/P&gt;&lt;P&gt;             from (p_table).&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;&lt;/P&gt;&lt;P&gt;form Write_Out.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Write out data from table.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  loop at &amp;lt;dyn_table&amp;gt; into &amp;lt;dyn_wa&amp;gt;.&lt;/P&gt;&lt;P&gt;    do.&lt;/P&gt;&lt;P&gt;      assign component  sy-index&lt;/P&gt;&lt;P&gt;         of structure &amp;lt;dyn_wa&amp;gt; to &amp;lt;dyn_field&amp;gt;.&lt;/P&gt;&lt;P&gt;      if sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;        exit.&lt;/P&gt;&lt;P&gt;      endif.&lt;/P&gt;&lt;P&gt;      if sy-index = 1.&lt;/P&gt;&lt;P&gt;        write:/ &amp;lt;dyn_field&amp;gt;.&lt;/P&gt;&lt;P&gt;      else.&lt;/P&gt;&lt;P&gt;        write: &amp;lt;dyn_field&amp;gt;.&lt;/P&gt;&lt;P&gt;      endif.&lt;/P&gt;&lt;P&gt;    enddo.&lt;/P&gt;&lt;P&gt;  endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Jun 2006 13:19:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-table-rich-prog/m-p/1421937#M202430</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-27T13:19:08Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic table (rich prog)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-table-rich-prog/m-p/1421938#M202431</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;how in the paramaters i can give him only a list of 10 tables &lt;/P&gt;&lt;P&gt;parameters: p_table(30) type c default 'T001'.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Jun 2006 13:21:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-table-rich-prog/m-p/1421938#M202431</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-27T13:21:08Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic table (rich prog)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-table-rich-prog/m-p/1421939#M202432</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is the modified program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

report z_dynamic.

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.
  perform get_data.
&amp;lt;b&amp;gt;  perform download_data.&amp;lt;/b&amp;gt;

*---------------------------------------------------------------------*
*       FORM get_structure                                            *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
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                                      *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
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                                                 *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
form get_data.

* Select Data from table.
  select * into table &amp;lt;dyn_table&amp;gt;
  from (p_table).

endform.



*---------------------------------------------------------------------*
*       FORM download_data                                            *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
&amp;lt;b&amp;gt;form download_data.

  data: iout type table of string with header line.

  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.
        iout = &amp;lt;dyn_field&amp;gt;.
      else.
        concatenate iout &amp;lt;dyn_field&amp;gt; into iout separated by ';'.
      endif.
    enddo.
    append iout.
  endloop.

  call function 'GUI_DOWNLOAD'
       exporting
            filename = 'C:text.txt'
       tables
            data_tab = iout.


endform.&amp;lt;/b&amp;gt;


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&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>Tue, 27 Jun 2006 13:29:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-table-rich-prog/m-p/1421939#M202432</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2006-06-27T13:29:35Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic table (rich prog)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-table-rich-prog/m-p/1421940#M202433</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks.&lt;/P&gt;&lt;P&gt;what about the second QA.&lt;/P&gt;&lt;P&gt;can i give him list for 10 tables only&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Jun 2006 13:40:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-table-rich-prog/m-p/1421940#M202433</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-27T13:40:14Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic table (rich prog)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-table-rich-prog/m-p/1421941#M202434</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You want to have a dropdown of 10 default tables?&lt;/P&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>Tue, 27 Jun 2006 13:47:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-table-rich-prog/m-p/1421941#M202434</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2006-06-27T13:47:46Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic table (rich prog)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-table-rich-prog/m-p/1421942#M202435</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;


report zrich_0001.

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.
&amp;lt;b&amp;gt;parameters: p_table as listbox visible length 30.&amp;lt;/b&amp;gt;
selection-screen end of block b1.


&amp;lt;b&amp;gt;at selection-screen output.

  perform build_table_drop_down_list.&amp;lt;/b&amp;gt;
start-of-selection.

  perform get_structure.
  perform create_dynamic_itab.
  perform get_data.
  perform download_data.

************************************************************************
* build table_drop_down_list
************************************************************************
&amp;lt;b&amp;gt;form build_table_drop_down_list.

type-pools: vrm.

  data: name type vrm_id,
        list type vrm_values,
        value like line of list.


  clear list. refresh list.
  name = 'P_TABLE'.

  clear value.
  value-key = 'T000'.
  value-text = 'T000'.
  append value to list.

  clear value.
  value-key = 'T001'.
  value-text = 'T001'.
  append value to list.

  clear value.
  value-key = 'T001A'.
  value-text = 'T001A'.
  append value to list.

  clear value.
  value-key = 'T001B'.
  value-text = 'T001B'.
  append value to list.

  clear value.
  value-key = 'T001C'.
  value-text = 'T001C'.
  append value to list.

  clear value.
  value-key = 'T001D'.
  value-text = 'T001D'.
  append value to list.

  clear value.
  value-key = 'T001E'.
  value-text = 'T001E'.
  append value to list.

* Set the values
  call function 'VRM_SET_VALUES'
       exporting
            id     = name
            values = list.

endform.&amp;lt;/b&amp;gt;

*---------------------------------------------------------------------*
*       FORM get_structure                                            *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
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                                      *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
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                                                 *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
form get_data.

* Select Data from table.
  select * into table &amp;lt;dyn_table&amp;gt;
  from (p_table).

endform.



*---------------------------------------------------------------------*
*       FORM download_data                                            *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
form download_data.

data: iout type table of string with header line.

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.
      iout = &amp;lt;dyn_field&amp;gt;.
    else.
      concatenate iout &amp;lt;dyn_field&amp;gt; into iout separated by ';'.
    endif.
  enddo.
  append iout.
endloop.

call function 'GUI_DOWNLOAD'
     exporting
          filename = 'C:text.txt'
     tables
          data_tab = iout.

endform.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&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>Tue, 27 Jun 2006 13:53:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-table-rich-prog/m-p/1421942#M202435</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2006-06-27T13:53:31Z</dc:date>
    </item>
  </channel>
</rss>

