<?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: Create dynamic internal table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-dynamic-internal-table/m-p/1748510#M324585</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;The concept of usinf field symbols is quite useful in creating dynamic objects.&lt;/P&gt;&lt;P&gt;Plz try the following code :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tables: rsrd1.&lt;/P&gt;&lt;P&gt;data: linetype type string,&lt;/P&gt;&lt;P&gt;        itabref  type ref to data,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;       wa_fs type ref to data.&lt;/P&gt;&lt;P&gt;data : wa_out type string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;field-symbols: &amp;lt;fs&amp;gt;  type standard table,&lt;/P&gt;&lt;P&gt;                   &amp;lt;fs1&amp;gt; type any  .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;parameter tbl like rsrd1-tbma_val.           " For table name &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;linetype = tbl.&lt;/P&gt;&lt;P&gt;" dynamic table creation &lt;/P&gt;&lt;P&gt;create data itabref type standard table of (linetype).&lt;/P&gt;&lt;P&gt;assign itabref-&amp;gt;* to &amp;lt;fs&amp;gt; .             " Assign object to Field symbol&lt;/P&gt;&lt;P&gt;                                                  " It now behaves like an int table with initial   &lt;/P&gt;&lt;P&gt;                                                 "  values &lt;/P&gt;&lt;P&gt;select * from (tbl) into table &amp;lt;fs&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;create data wa_fs like line of &amp;lt;fs&amp;gt;.&lt;/P&gt;&lt;P&gt;assign wa_fs-&amp;gt;* to &amp;lt;fs1&amp;gt; .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at &amp;lt;fs&amp;gt; into &amp;lt;fs1&amp;gt; . " or    assigning &amp;lt;fs1&amp;gt;.   even this works&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;write &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt; 'done' .&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;Pankaj&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 15 Dec 2006 04:52:07 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-12-15T04:52:07Z</dc:date>
    <item>
      <title>Create dynamic internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-dynamic-internal-table/m-p/1748507#M324582</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;could anyone please give me the code on creating an internal table dynamically?&lt;/P&gt;&lt;P&gt;i want to create an internal table which i can add or remove a field as the program runs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Dec 2006 04:20:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-dynamic-internal-table/m-p/1748507#M324582</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-12-15T04:20:18Z</dc:date>
    </item>
    <item>
      <title>Re: Create dynamic internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-dynamic-internal-table/m-p/1748508#M324583</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;Check this sample code from other thread.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
===================================== 
REPORT zmaschl_create_data_dynamic . 

TYPE-POOLS: slis. 

DATA: it_fcat TYPE slis_t_fieldcat_alv, 
is_fcat LIKE LINE OF it_fcat. 
DATA: it_fieldcat TYPE lvc_t_fcat, 
is_fieldcat LIKE LINE OF it_fieldcat. 
DATA: new_table TYPE REF TO data. 
DATA: new_line TYPE REF TO data. 
FIELD-SYMBOLS: &amp;lt;l_table&amp;gt; TYPE ANY TABLE, 
&amp;lt;l_line&amp;gt; TYPE ANY, 
&amp;lt;l_field&amp;gt; TYPE ANY. 

* Build fieldcat 
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE' 
EXPORTING 
i_structure_name = 'SYST' 
CHANGING 
ct_fieldcat = it_fcat[]. 
LOOP AT it_fcat INTO is_fcat WHERE NOT reptext_ddic IS initial. 
MOVE-CORRESPONDING is_fcat TO is_fieldcat. 
is_fieldcat-fieldname = is_fcat-fieldname. 
is_fieldcat-ref_field = is_fcat-fieldname. 
is_fieldcat-ref_table = is_fcat-ref_tabname. 
APPEND is_fieldcat TO it_fieldcat. 
ENDLOOP. 

* Create a new Table 
CALL METHOD cl_alv_table_create=&amp;gt;create_dynamic_table 
EXPORTING 
it_fieldcatalog = it_fieldcat 
IMPORTING 
ep_table = new_table. 

* Create a new Line with the same structure of the table. 
ASSIGN new_table-&amp;gt;* TO &amp;lt;l_table&amp;gt;. 
CREATE DATA new_line LIKE LINE OF &amp;lt;l_table&amp;gt;. 
ASSIGN new_line-&amp;gt;* TO &amp;lt;l_line&amp;gt;. 

* Test it... 
DO 30 TIMES. 
ASSIGN COMPONENT 'SUBRC' OF STRUCTURE &amp;lt;l_line&amp;gt; TO &amp;lt;l_field&amp;gt;. 
&amp;lt;l_field&amp;gt; = sy-index. 
INSERT &amp;lt;l_line&amp;gt; INTO TABLE &amp;lt;l_table&amp;gt;. 
ENDDO. 

LOOP AT &amp;lt;l_table&amp;gt; ASSIGNING &amp;lt;l_line&amp;gt;. 
ASSIGN COMPONENT 'SUBRC' OF STRUCTURE &amp;lt;l_line&amp;gt; TO &amp;lt;l_field&amp;gt;. 
WRITE &amp;lt;l_field&amp;gt;. 
ENDLOOP. 
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this will help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ferry Liato&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Dec 2006 04:31:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-dynamic-internal-table/m-p/1748508#M324583</guid>
      <dc:creator>ferry_lianto</dc:creator>
      <dc:date>2006-12-15T04:31:34Z</dc:date>
    </item>
    <item>
      <title>Re: Create dynamic internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-dynamic-internal-table/m-p/1748509#M324584</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jesus,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Create a fieldcatalog with the desired fields and the call the method given below this creates a internal table at runtime.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  DATA: lt_fieldcat      TYPE lvc_t_fcat.&lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS:&amp;lt;GT_TABLE1&amp;gt; TYPE 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 it_fieldcatalog = lt_fieldcat&lt;/P&gt;&lt;P&gt;                           IMPORTING ep_table = lp_table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    ASSIGN lp_table-&amp;gt;* TO &amp;lt;gt_table1&amp;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;Sourabh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Dec 2006 04:39:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-dynamic-internal-table/m-p/1748509#M324584</guid>
      <dc:creator>sourabhshah</dc:creator>
      <dc:date>2006-12-15T04:39:38Z</dc:date>
    </item>
    <item>
      <title>Re: Create dynamic internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-dynamic-internal-table/m-p/1748510#M324585</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;The concept of usinf field symbols is quite useful in creating dynamic objects.&lt;/P&gt;&lt;P&gt;Plz try the following code :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tables: rsrd1.&lt;/P&gt;&lt;P&gt;data: linetype type string,&lt;/P&gt;&lt;P&gt;        itabref  type ref to data,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;       wa_fs type ref to data.&lt;/P&gt;&lt;P&gt;data : wa_out type string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;field-symbols: &amp;lt;fs&amp;gt;  type standard table,&lt;/P&gt;&lt;P&gt;                   &amp;lt;fs1&amp;gt; type any  .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;parameter tbl like rsrd1-tbma_val.           " For table name &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;linetype = tbl.&lt;/P&gt;&lt;P&gt;" dynamic table creation &lt;/P&gt;&lt;P&gt;create data itabref type standard table of (linetype).&lt;/P&gt;&lt;P&gt;assign itabref-&amp;gt;* to &amp;lt;fs&amp;gt; .             " Assign object to Field symbol&lt;/P&gt;&lt;P&gt;                                                  " It now behaves like an int table with initial   &lt;/P&gt;&lt;P&gt;                                                 "  values &lt;/P&gt;&lt;P&gt;select * from (tbl) into table &amp;lt;fs&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;create data wa_fs like line of &amp;lt;fs&amp;gt;.&lt;/P&gt;&lt;P&gt;assign wa_fs-&amp;gt;* to &amp;lt;fs1&amp;gt; .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at &amp;lt;fs&amp;gt; into &amp;lt;fs1&amp;gt; . " or    assigning &amp;lt;fs1&amp;gt;.   even this works&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;write &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt; 'done' .&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;Pankaj&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Dec 2006 04:52:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-dynamic-internal-table/m-p/1748510#M324585</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-12-15T04:52:07Z</dc:date>
    </item>
  </channel>
</rss>

