<?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: Fill a dynamic table by column in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/fill-a-dynamic-table-by-column/m-p/7074968#M1505146</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can do it by using ASSIGN statement with option COMPONENT comp OF STRUCTURE struc.&lt;/P&gt;&lt;P&gt;Check this link for more details.&lt;/P&gt;&lt;P&gt;[http://help.sap.com/saphelp_wp/helpdata/en/fc/eb3923358411d1829f0000e829fbfe/content.htm]&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 28 Jun 2010 10:14:50 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-06-28T10:14:50Z</dc:date>
    <item>
      <title>Fill a dynamic table by column</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fill-a-dynamic-table-by-column/m-p/7074967#M1505145</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I search without success how i can fill a dynamic table or a table by column.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have an internal table of a column and a dynamic table of 100 column.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want make a loop to fill each column of the dynamic table from the column of my internal table (values change for each loop) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help&lt;/P&gt;&lt;P&gt;Rodolphe.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Jun 2010 10:02:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fill-a-dynamic-table-by-column/m-p/7074967#M1505145</guid>
      <dc:creator>former_member215107</dc:creator>
      <dc:date>2010-06-28T10:02:35Z</dc:date>
    </item>
    <item>
      <title>Re: Fill a dynamic table by column</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fill-a-dynamic-table-by-column/m-p/7074968#M1505146</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can do it by using ASSIGN statement with option COMPONENT comp OF STRUCTURE struc.&lt;/P&gt;&lt;P&gt;Check this link for more details.&lt;/P&gt;&lt;P&gt;[http://help.sap.com/saphelp_wp/helpdata/en/fc/eb3923358411d1829f0000e829fbfe/content.htm]&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Jun 2010 10:14:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fill-a-dynamic-table-by-column/m-p/7074968#M1505146</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-06-28T10:14:50Z</dc:date>
    </item>
    <item>
      <title>Re: Fill a dynamic table by column</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fill-a-dynamic-table-by-column/m-p/7074969#M1505147</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 with below code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;* Data declaration for Internal table creation
DATA: i_new_table  TYPE REF TO data,             " Internal Table
      wa_new_line  TYPE REF TO data,             " Workarea
      wa_lvc_cat   TYPE lvc_s_fcat,               " Fieldcatalog LS
      i_lvc_cat    TYPE lvc_t_fcat.               " Fieldcatalog IT

* Field symbols
FIELD-SYMBOLS: &amp;lt;i_table&amp;gt;  TYPE table,            " For Table
               &amp;lt;wa_line&amp;gt;  TYPE ANY,              " For Workarea
               &amp;lt;v_field&amp;gt;  TYPE ANY.              " For Field


LOOP AT i_column INTO wa_column.

     lv_cpos = lv_cpos + 1.

      wa_lvc_cat-fieldname = wa_column-field.
      wa_lvc_cat-reptext = wa_column-field.
      wa_lvc_cat-coltext   = wa_column-field.
      wa_lvc_cat-outputlen = 10.
      wa_lvc_cat-col_pos   = lv_cpos.
      APPEND wa_lvc_cat TO i_lvc_cat.

CLEAR : wa_column, wa_lvc_cat.

ENDLOOP.


* Create a new Table
  CALL METHOD cl_alv_table_create=&amp;gt;create_dynamic_table
    EXPORTING
      it_fieldcatalog = i_lvc_cat
    IMPORTING
      ep_table        = i_new_table.

* Assign the table to a field symbol
  ASSIGN i_new_table-&amp;gt;* TO &amp;lt;i_table&amp;gt;.

* Create a workarea of table structure
  CREATE DATA wa_new_line LIKE LINE OF &amp;lt;i_table&amp;gt;. " Internal table

* Assign to a field symbol
  ASSIGN wa_new_line-&amp;gt;* TO &amp;lt;wa_line&amp;gt;.        " Work area&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have field length and text as well in your column internal table pass them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Bala Krishna&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Jun 2010 10:36:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fill-a-dynamic-table-by-column/m-p/7074969#M1505147</guid>
      <dc:creator>former_member585060</dc:creator>
      <dc:date>2010-06-28T10:36:48Z</dc:date>
    </item>
    <item>
      <title>Re: Fill a dynamic table by column</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fill-a-dynamic-table-by-column/m-p/7074970#M1505148</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;&lt;/P&gt;&lt;P&gt;When I try the following code, here the result in my table:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;COLUMN1__COLUMN2__COLUMN3&lt;/P&gt;&lt;P&gt;A&lt;/P&gt;&lt;P&gt;B&lt;/P&gt;&lt;P&gt;C&lt;/P&gt;&lt;P&gt;______________D&lt;/P&gt;&lt;P&gt;______________E&lt;/P&gt;&lt;P&gt;______________F&lt;/P&gt;&lt;P&gt;________________________G&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like this result:&lt;/P&gt;&lt;P&gt;COLUMN1__COLUMN2__COLUMN3&lt;/P&gt;&lt;P&gt;A____________D_________G&lt;/P&gt;&lt;P&gt;B____________E_________&lt;/P&gt;&lt;P&gt;C____________F_________&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here my code:&lt;/P&gt;&lt;P&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;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;fs&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Compute the total length of ZTABLE_CHECK_ROL&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  select * from ZTABLE_CHECK_ROL.&lt;/P&gt;&lt;P&gt;  endselect.&lt;/P&gt;&lt;P&gt;  i_table_length = sy-dbcnt.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Create Field Catalog&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  ICount = 1.&lt;/P&gt;&lt;P&gt;  DO i_table_length TIMES.&lt;/P&gt;&lt;P&gt;   &lt;/P&gt;&lt;P&gt;    c_tmpchar = ICount.&lt;/P&gt;&lt;P&gt;    concatenate 'COL' c_tmpchar into ls_fcat-fieldname.&lt;/P&gt;&lt;P&gt;    CONDENSE ls_fcat-fieldname NO-GAPS.&lt;/P&gt;&lt;P&gt;    ls_fcat-ref_field = 'NAMEROLE'.&lt;/P&gt;&lt;P&gt;    ls_fcat-ref_table = 'ZTABLE_CHECK_ROL'.&lt;/P&gt;&lt;P&gt;    APPEND ls_fcat TO lt_fcat.&lt;/P&gt;&lt;P&gt;    CLEAR: ls_fcat, c_tmpchar.&lt;/P&gt;&lt;P&gt;    ICount = ICount + 1.&lt;/P&gt;&lt;P&gt;  ENDDO.&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  = lt_fcat&lt;/P&gt;&lt;P&gt;    IMPORTING&lt;/P&gt;&lt;P&gt;      ep_table         = dy_table.&lt;/P&gt;&lt;P&gt;  ASSIGN dy_table-&amp;gt;* TO &amp;lt;dyn_table&amp;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;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;1- Create internal table which lists a role and its associated users&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;2- Affect the internal table to a column of an internal table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;ICount = 1.&lt;/P&gt;&lt;P&gt;select * from ZTABLE_CHECK_ROL into wa_ZTABLE_CHECK_ROL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     select UNAME from AGR_USERS into table INTERNTABLE_USERLIST&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      select UNAME from AGR_USERS into wa_uname&lt;/P&gt;&lt;P&gt;      where AGR_NAME = wa_ZTABLE_CHECK_ROL-NAMEROLE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;             c_tmpchar = ICount.&lt;/P&gt;&lt;P&gt;            concatenate 'COL' c_tmpchar into l_col.&lt;/P&gt;&lt;P&gt;            CONDENSE l_col NO-GAPS.&lt;/P&gt;&lt;P&gt;            ASSIGN COMPONENT l_col OF STRUCTURE &amp;lt;dyn_wa&amp;gt; TO &amp;lt;fs&amp;gt;.&lt;/P&gt;&lt;P&gt;            IF SY-SUBRC = 0.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;           &amp;lt;fs&amp;gt; = INTERNTABLE_USERLIST.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;              &amp;lt;fs&amp;gt; = wa_uname.&lt;/P&gt;&lt;P&gt;            ENDIF.&lt;/P&gt;&lt;P&gt;            UNASSIGN &amp;lt;fs&amp;gt;.&lt;/P&gt;&lt;P&gt;            APPEND &amp;lt;dyn_wa&amp;gt; TO &amp;lt;dyn_table&amp;gt;.&lt;/P&gt;&lt;P&gt;      endselect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    Treatment of the next role&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      ICount = ICount + 1.&lt;/P&gt;&lt;P&gt;endselect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot for your help&lt;/P&gt;&lt;P&gt;Rodolphe.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Jun 2010 13:45:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fill-a-dynamic-table-by-column/m-p/7074970#M1505148</guid>
      <dc:creator>former_member215107</dc:creator>
      <dc:date>2010-06-28T13:45:47Z</dc:date>
    </item>
    <item>
      <title>Re: Fill a dynamic table by column</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fill-a-dynamic-table-by-column/m-p/7074971#M1505149</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;    In your code for preparing the fieldcatalog, the column position is missing, add that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DO i_table_length TIMES.

c_tmpchar = ICount.
concatenate 'COL' c_tmpchar into ls_fcat-fieldname.
CONDENSE ls_fcat-fieldname NO-GAPS.

ls_fcat-ref_field = 'NAMEROLE'.
ls_fcat-ref_table = 'ZTABLE_CHECK_ROL'.
ls_fcat-col_pos = ICount.                           " this missing in your code, it will specify the field column no

APPEND ls_fcat TO lt_fcat.
CLEAR: ls_fcat, c_tmpchar.
ICount = ICount + 1.

ENDDO.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of SELECT and ELDSELECT, try to fetch all the records in single hit to database and then loop that table, as with your code, for each entry it will access the database that many times, it may effect the performance of the program.&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;Bala Krishna&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Jun 2010 14:39:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fill-a-dynamic-table-by-column/m-p/7074971#M1505149</guid>
      <dc:creator>former_member585060</dc:creator>
      <dc:date>2010-06-28T14:39:07Z</dc:date>
    </item>
  </channel>
</rss>

