<?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 ALV in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-alv/m-p/1613185#M274816</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is an example program which you can use to build your program.&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>Tue, 10 Oct 2006 13:02:43 GMT</pubDate>
    <dc:creator>RichHeilman</dc:creator>
    <dc:date>2006-10-10T13:02:43Z</dc:date>
    <item>
      <title>Dynamic ALV</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-alv/m-p/1613184#M274815</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi friends,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;          I have requirement to display output listin ALV. &lt;/P&gt;&lt;P&gt;Once user entered in selection screen input Work order type (1,2...6). if user select order type 1 and 2 . the display like this Plant, Plant description, No of ord1, &lt;/P&gt;&lt;P&gt;%no of ord1, No of Ord2, % no of ord2, Total no of Orders.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if the user seleceted order type 1, 2, and 4. The output display like this &lt;/P&gt;&lt;P&gt;Plant, Plant description, No of ord1, &lt;/P&gt;&lt;P&gt;%no of ord1, No of Ord2, % no of ord2, no of ord4, % No of ord4 , Total no of Orders.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Its urgent requirement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Oct 2006 12:59:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-alv/m-p/1613184#M274815</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-10-10T12:59:11Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic ALV</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-alv/m-p/1613185#M274816</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is an example program which you can use to build your program.&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>Tue, 10 Oct 2006 13:02:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-alv/m-p/1613185#M274816</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2006-10-10T13:02:43Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic ALV</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-alv/m-p/1613186#M274817</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If depend on the fieldcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If workorder = '2'.&lt;/P&gt;&lt;P&gt;Built the fieldcat depending on ur réquirement&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Similarly for alll the inputs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If useful reward.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Vasanth&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Oct 2006 13:03:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-alv/m-p/1613186#M274817</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-10-10T13:03:45Z</dc:date>
    </item>
  </channel>
</rss>

