<?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: Populate Dynamic Table using field symbol in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/populate-dynamic-table-using-field-symbol/m-p/5173241#M1197750</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Check this code&lt;/P&gt;&lt;P&gt;type-pools : abap.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
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.

data : idetails type abap_compdescr_tab,
       xdetails type abap_compdescr.

data : ref_table_des type ref to cl_abap_structdescr.
data : begin of ta_ouput occurs 0,
rowPos(10) type i,
colPos(10) type i,
level(1) type i,
text(200) type c,
end of ta_output.

* Get the structure of the table.

    xfc-fieldname = 'ROWPOS' .
    xfc-inttype = 'CHAR'.
    xfc-intlen = '10'.
    append xfc to ifc.

    xfc-fieldname = 'COLPOS' .
    xfc-inttype = 'CHAR'.
    xfc-intlen = '10'.
    append xfc to ifc.

    xfc-fieldname = 'LEVEL' .
    xfc-inttype = 'CHAR'.
    xfc-intlen = '1'.
    append xfc to ifc.

    xfc-fieldname = 'TEXT' .
    xfc-inttype = 'CHAR'.
    xfc-intlen = '200'.
    append xfc to ifc.

* 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;.

* MOVE oyur data accordingly into it.

* 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;hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Prashanth&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 19 Feb 2009 15:15:22 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-02-19T15:15:22Z</dc:date>
    <item>
      <title>Populate Dynamic Table using field symbol</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/populate-dynamic-table-using-field-symbol/m-p/5173240#M1197749</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm newbie in dynamic table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have 1 internal table called ta_output as defined below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : begin of ta_ouput occurs 0,&lt;/P&gt;&lt;P&gt;           rowPos(10)  type i,&lt;/P&gt;&lt;P&gt;           colPos(10)   type i,&lt;/P&gt;&lt;P&gt;           level(1)        type i,&lt;/P&gt;&lt;P&gt;           text(200)     type c,&lt;/P&gt;&lt;P&gt;         end of ta_output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ta_OUTPUT has been populated like below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rowPos    colPos        level              text&lt;/P&gt;&lt;P&gt;    1             1              A                Shop&lt;/P&gt;&lt;P&gt;    1             2              A                Condominium&lt;/P&gt;&lt;P&gt;    1             3              A                School&lt;/P&gt;&lt;P&gt;    2             1              B                100 &lt;/P&gt;&lt;P&gt;    2             2              B                  5       &lt;/P&gt;&lt;P&gt;    2             3              B                 12   &lt;/P&gt;&lt;P&gt;    3             1              B                 40 &lt;/P&gt;&lt;P&gt;    3             2              B                 16      &lt;/P&gt;&lt;P&gt;    3             3              B                 10   &lt;/P&gt;&lt;P&gt;    4             1              B                 0 &lt;/P&gt;&lt;P&gt;    4             2              B                 25      &lt;/P&gt;&lt;P&gt;    4             3              B                 7  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to populate dynamic listing like below using that ta_output:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Shop                   Condominium             School&lt;/P&gt;&lt;P&gt;100                           5                              12&lt;/P&gt;&lt;P&gt; 40                           16                             10&lt;/P&gt;&lt;P&gt;  0                            25                              7&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Feb 2009 07:09:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/populate-dynamic-table-using-field-symbol/m-p/5173240#M1197749</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-19T07:09:54Z</dc:date>
    </item>
    <item>
      <title>Re: Populate Dynamic Table using field symbol</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/populate-dynamic-table-using-field-symbol/m-p/5173241#M1197750</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Check this code&lt;/P&gt;&lt;P&gt;type-pools : abap.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
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.

data : idetails type abap_compdescr_tab,
       xdetails type abap_compdescr.

data : ref_table_des type ref to cl_abap_structdescr.
data : begin of ta_ouput occurs 0,
rowPos(10) type i,
colPos(10) type i,
level(1) type i,
text(200) type c,
end of ta_output.

* Get the structure of the table.

    xfc-fieldname = 'ROWPOS' .
    xfc-inttype = 'CHAR'.
    xfc-intlen = '10'.
    append xfc to ifc.

    xfc-fieldname = 'COLPOS' .
    xfc-inttype = 'CHAR'.
    xfc-intlen = '10'.
    append xfc to ifc.

    xfc-fieldname = 'LEVEL' .
    xfc-inttype = 'CHAR'.
    xfc-intlen = '1'.
    append xfc to ifc.

    xfc-fieldname = 'TEXT' .
    xfc-inttype = 'CHAR'.
    xfc-intlen = '200'.
    append xfc to ifc.

* 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;.

* MOVE oyur data accordingly into it.

* 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;hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Prashanth&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Feb 2009 15:15:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/populate-dynamic-table-using-field-symbol/m-p/5173241#M1197750</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-19T15:15:22Z</dc:date>
    </item>
    <item>
      <title>Re: Populate Dynamic Table using field symbol</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/populate-dynamic-table-using-field-symbol/m-p/5173242#M1197751</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;DATA : wa_fcat TYPE lvc_s_fcat,&lt;/P&gt;&lt;P&gt;         it_fcat TYPE lvc_t_fcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS: &amp;lt;fs_table&amp;gt; TYPE table,&lt;/P&gt;&lt;P&gt;               &amp;lt;fs_any&amp;gt; TYPE ANY,&lt;/P&gt;&lt;P&gt;               &amp;lt;fs_wa&amp;gt; TYPE ANY,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  DATA : it_tab TYPE REF TO data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*creating the structure&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  wa_fcat-fieldname = 'MATNR'.&lt;/P&gt;&lt;P&gt;  wa_fcat-tabname = 'IT_TAB'.&lt;/P&gt;&lt;P&gt;  wa_fcat-reptext = 'Material'.&lt;/P&gt;&lt;P&gt;  wa_fcat-outputlen = 15.&lt;/P&gt;&lt;P&gt;  APPEND wa_fcat TO it_fcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  wa_fcat-fieldname = 'MAKTX'.&lt;/P&gt;&lt;P&gt;  wa_fcat-tabname = 'IT_TAB'.&lt;/P&gt;&lt;P&gt;  wa_fcat-reptext = 'Material Desc.'.&lt;/P&gt;&lt;P&gt;  wa_fcat-outputlen = 35.&lt;/P&gt;&lt;P&gt;  APPEND wa_fcat TO it_fcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*method for dynamic table&lt;/P&gt;&lt;P&gt;&lt;/P&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;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      i_style_table             =&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      it_fieldcatalog            = it_fcat&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      i_length_in_byte          =&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    IMPORTING&lt;/P&gt;&lt;P&gt;      ep_table                   = it_tab&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      e_style_fname             =&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    EXCEPTIONS&lt;/P&gt;&lt;P&gt;      generate_subpool_dir_full = 1&lt;/P&gt;&lt;P&gt;      OTHERS                    = 2&lt;/P&gt;&lt;P&gt;       .&lt;/P&gt;&lt;P&gt;  IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; ASSIGN it_tab-&amp;gt;* TO &amp;lt;fs_table&amp;gt; .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CREATE DATA wa_line LIKE LINE OF &amp;lt;fs_table&amp;gt;.&lt;/P&gt;&lt;P&gt;  ASSIGN wa_line-&amp;gt;* TO &amp;lt;fs_wa&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at it_final into wa_final. "table in which ur data is there&lt;/P&gt;&lt;P&gt;*material&lt;/P&gt;&lt;P&gt;    ASSIGN COMPONENT c_mat OF STRUCTURE &amp;lt;fs_wa&amp;gt; TO &amp;lt;fs_any&amp;gt;.&lt;/P&gt;&lt;P&gt;    &amp;lt;fs_any&amp;gt; = wa_final-matnr.&lt;/P&gt;&lt;P&gt;    UNASSIGN &amp;lt;fs_any&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*mat. desc&lt;/P&gt;&lt;P&gt;    ASSIGN COMPONENT c_mat_desc OF STRUCTURE &amp;lt;fs_wa&amp;gt; TO &amp;lt;fs_any&amp;gt;.&lt;/P&gt;&lt;P&gt;    &amp;lt;fs_any&amp;gt; = wa_final-maktx.&lt;/P&gt;&lt;P&gt;    UNASSIGN &amp;lt;fs_any&amp;gt;.&lt;/P&gt;&lt;P&gt; APPEND &amp;lt;fs_wa&amp;gt; TO &amp;lt;fs_table&amp;gt;.&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;call function to display list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Anagha Deshmukh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Feb 2009 10:08:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/populate-dynamic-table-using-field-symbol/m-p/5173242#M1197751</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-20T10:08:49Z</dc:date>
    </item>
  </channel>
</rss>

