<?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 internal table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table/m-p/1596489#M267903</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;checkout this Program:-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;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. 
&amp;lt;b&amp;gt;  perform create_dynamic_itab. &amp;lt;/b&amp;gt;   
  perform get_data. 
  perform write_out. 
  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. 
  * 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. 
  * Select Data from table. 
  select * into table &amp;lt;dyn_table&amp;gt; 
             from (p_table). 
  endform. 
   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;Checkout this Blog for more info and more example:&lt;/P&gt;&lt;P&gt;/people/rich.heilman2/blog/2005/07/27/dynamic-internal-tables-and-structures--abap&lt;/P&gt;&lt;P&gt;&lt;A href="http://searchsap.techtarget.com/tip/1,289483,sid21_gci912390,00.html" target="test_blank"&gt;http://searchsap.techtarget.com/tip/1,289483,sid21_gci912390,00.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sap-img.com/ab030.htm" target="test_blank"&gt;http://www.sap-img.com/ab030.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Sudheer&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 22 Sep 2006 06:28:43 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-09-22T06:28:43Z</dc:date>
    <item>
      <title>dynamic internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table/m-p/1596487#M267901</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;Can anybody explain me the concept of dynamic internal tables and give me an example.?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Br,&lt;/P&gt;&lt;P&gt;Anil&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Sep 2006 06:11:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table/m-p/1596487#M267901</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-22T06:11:04Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table/m-p/1596488#M267902</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_message" href="https://community.sap.com/" __jive_macro_name="message" modifiedtitle="true" __default_attr="797696"&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Sep 2006 06:13:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table/m-p/1596488#M267902</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-22T06:13:53Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table/m-p/1596489#M267903</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;checkout this Program:-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;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. 
&amp;lt;b&amp;gt;  perform create_dynamic_itab. &amp;lt;/b&amp;gt;   
  perform get_data. 
  perform write_out. 
  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. 
  * 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. 
  * Select Data from table. 
  select * into table &amp;lt;dyn_table&amp;gt; 
             from (p_table). 
  endform. 
   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;Checkout this Blog for more info and more example:&lt;/P&gt;&lt;P&gt;/people/rich.heilman2/blog/2005/07/27/dynamic-internal-tables-and-structures--abap&lt;/P&gt;&lt;P&gt;&lt;A href="http://searchsap.techtarget.com/tip/1,289483,sid21_gci912390,00.html" target="test_blank"&gt;http://searchsap.techtarget.com/tip/1,289483,sid21_gci912390,00.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sap-img.com/ab030.htm" target="test_blank"&gt;http://www.sap-img.com/ab030.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Sudheer&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Sep 2006 06:28:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table/m-p/1596489#M267903</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-22T06:28:43Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table/m-p/1596490#M267904</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi anil,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;An internal table,&lt;/P&gt;&lt;P&gt;whose fields, data types,&lt;/P&gt;&lt;P&gt;are only specified/know at the runtime,&lt;/P&gt;&lt;P&gt;and not while creating the program&lt;/P&gt;&lt;P&gt;--- this is called dynamic internal table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. &lt;/P&gt;&lt;P&gt;  For this purpose,&lt;/P&gt;&lt;P&gt;  in my program,&lt;/P&gt;&lt;P&gt;  there is an INDEPENDENT FORM &lt;/P&gt;&lt;P&gt;  whose inputs are &lt;/P&gt;&lt;P&gt;  TABLE NAME / STRUCTURE NAME&lt;/P&gt;&lt;P&gt;  and from those, it consructs dynamic table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Here is the program.&lt;/P&gt;&lt;P&gt;the dynamic table name will be &lt;/P&gt;&lt;P&gt;&amp;lt;DYNTABLE&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. U can use this program (FORM in this program)&lt;/P&gt;&lt;P&gt;to generate any kind of internal table&lt;/P&gt;&lt;P&gt;by specifying TABLE NAME .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT abc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*----&lt;/P&gt;&lt;HR originaltext="--------" /&gt;&lt;P&gt; COMPULSORY&lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS: &amp;lt;dyntable&amp;gt; TYPE ANY TABLE.&lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS: &amp;lt;dynline&amp;gt; TYPE ANY.&lt;/P&gt;&lt;P&gt;DATA: lt TYPE lvc_t_fcat.&lt;/P&gt;&lt;P&gt;DATA: ls TYPE lvc_s_fcat.&lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS: &amp;lt;fld&amp;gt; TYPE ANY.&lt;/P&gt;&lt;P&gt;DATA : fldname(50) TYPE c.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*----&lt;/P&gt;&lt;HR originaltext="---------------" /&gt;&lt;P&gt;parameters : iname LIKE dd02l-tabname.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*----&lt;/P&gt;&lt;HR originaltext="---------------" /&gt;&lt;P&gt;&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;*----&lt;/P&gt;&lt;HR originaltext="---------" /&gt;&lt;P&gt; PERFORM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM mydyntable USING lt.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BREAK-POINT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*----&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------" /&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;INDEPENDENT FORM&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;*----&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM mydyntable USING ptabname.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*----&lt;/P&gt;&lt;HR originaltext="---------" /&gt;&lt;P&gt; Create Dyn Table From FC&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS: &amp;lt;fs_data&amp;gt; TYPE REF TO data.&lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS: &amp;lt;fs_1&amp;gt;.&lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS: &amp;lt;fs_2&amp;gt; TYPE ANY TABLE.&lt;/P&gt;&lt;P&gt;DATA: lt_data TYPE REF TO data.&lt;/P&gt;&lt;P&gt;data : lt TYPE lvc_t_fcat .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA : ddfields LIKE ddfield OCCURS 0 WITH HEADER LINE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*----&lt;/P&gt;&lt;HR originaltext="--------------------------------------" /&gt;&lt;P&gt;CALL FUNCTION 'DD_NAMETAB_TO_DDFIELDS'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;tabname = iname&lt;/P&gt;&lt;P&gt;TABLES&lt;/P&gt;&lt;P&gt;ddfields = ddfields.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*----&lt;/P&gt;&lt;HR originaltext="--------" /&gt;&lt;P&gt; CONSTRUCT FIELD LIST&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT ddfields.&lt;/P&gt;&lt;P&gt;ls-fieldname = ddfields-fieldname.&lt;/P&gt;&lt;P&gt;APPEND ls TO lt.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ASSIGN lt_data TO &amp;lt;fs_data&amp;gt;.&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;P&gt;it_fieldcatalog = lt&lt;/P&gt;&lt;P&gt;IMPORTING&lt;/P&gt;&lt;P&gt;ep_table = &amp;lt;fs_data&amp;gt;&lt;/P&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;IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*----&lt;/P&gt;&lt;HR originaltext="--------" /&gt;&lt;P&gt; Assign Dyn Table To Field Sumbol&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ASSIGN &amp;lt;fs_data&amp;gt;-&amp;gt;* TO &amp;lt;fs_1&amp;gt;.&lt;/P&gt;&lt;P&gt;ASSIGN &amp;lt;fs_1&amp;gt; TO &amp;lt;fs_2&amp;gt;.&lt;/P&gt;&lt;P&gt;ASSIGN &amp;lt;fs_1&amp;gt; TO &amp;lt;dyntable&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDFORM. "MYDYNTABLE&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;amit m.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Sep 2006 06:44:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table/m-p/1596490#M267904</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-22T06:44:21Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table/m-p/1596491#M267905</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_message" href="https://community.sap.com/" __jive_macro_name="message" modifiedtitle="true" __default_attr="2135418"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check this link.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Srikanth&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Sep 2006 07:37:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table/m-p/1596491#M267905</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-22T07:37:09Z</dc:date>
    </item>
  </channel>
</rss>

