<?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 Creating dynamic internal table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/creating-dynamic-internal-table/m-p/3427963#M823335</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have this input field called IO_TABLE and a button. When the user key in the database name into IO_TABLE and press the button, the records/data in the database will be written out. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is my codes when the button is clicked:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  ASSIGN IO_TABLE TO &amp;lt;FS_INPUT&amp;gt;.

  SELECT * FROM &amp;lt;FS_INPUT&amp;gt; INTO TABLE *dynamic internal table*.
  WRITE *dynamic internal table* .
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As shown &amp;lt;FS_INPUT&amp;gt; is the field symbol that store the value of IO_TABLE. What am I suppose to replace my &lt;STRONG&gt;dynamic internal table&lt;/STRONG&gt; for my codes?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;dynamic internal table&lt;/STRONG&gt; is needed to display out the values in it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 14 Feb 2008 09:41:36 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-02-14T09:41:36Z</dc:date>
    <item>
      <title>Creating dynamic internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/creating-dynamic-internal-table/m-p/3427963#M823335</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have this input field called IO_TABLE and a button. When the user key in the database name into IO_TABLE and press the button, the records/data in the database will be written out. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is my codes when the button is clicked:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  ASSIGN IO_TABLE TO &amp;lt;FS_INPUT&amp;gt;.

  SELECT * FROM &amp;lt;FS_INPUT&amp;gt; INTO TABLE *dynamic internal table*.
  WRITE *dynamic internal table* .
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As shown &amp;lt;FS_INPUT&amp;gt; is the field symbol that store the value of IO_TABLE. What am I suppose to replace my &lt;STRONG&gt;dynamic internal table&lt;/STRONG&gt; for my codes?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;dynamic internal table&lt;/STRONG&gt; is needed to display out the values in it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Feb 2008 09:41:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/creating-dynamic-internal-table/m-p/3427963#M823335</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-14T09:41:36Z</dc:date>
    </item>
    <item>
      <title>Re: Creating dynamic internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/creating-dynamic-internal-table/m-p/3427964#M823336</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;To create a Dynamic Internal table .Just chek out this program . &lt;/P&gt;&lt;P&gt;    &lt;/P&gt;&lt;P&gt;  type-pools : abap. &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;dyn_field&amp;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;      xfc type lvc_s_fcat, &lt;/P&gt;&lt;P&gt;      ifc type lvc_t_fcat. &lt;/P&gt;&lt;P&gt;  selection-screen begin of block b1 with frame. &lt;/P&gt;&lt;P&gt;parameters: p_table(30) type c default 'T001'. &lt;/P&gt;&lt;P&gt;selection-screen end of block b1. &lt;/P&gt;&lt;P&gt;  start-of-selection. &lt;/P&gt;&lt;P&gt;    perform get_structure. &lt;/P&gt;&lt;P&gt;  perform create_dynamic_itab.      *********&lt;STRONG&gt;Creates a dyanamic internal table&lt;/STRONG&gt;********* &lt;/P&gt;&lt;P&gt;  perform get_data. &lt;/P&gt;&lt;P&gt;  perform write_out. &lt;/P&gt;&lt;P&gt;  form get_structure. &lt;/P&gt;&lt;P&gt;  data : idetails type abap_compdescr_tab, &lt;/P&gt;&lt;P&gt;       xdetails type abap_compdescr. &lt;/P&gt;&lt;P&gt;  data : ref_table_des type ref to cl_abap_structdescr. &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Get the structure of the table. &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  ref_table_des ?=  &lt;/P&gt;&lt;P&gt;      cl_abap_typedescr=&amp;gt;describe_by_name( p_table ). &lt;/P&gt;&lt;P&gt;  idetails[] = ref_table_des-&amp;gt;components[]. &lt;/P&gt;&lt;P&gt;    loop at idetails into xdetails. &lt;/P&gt;&lt;P&gt;    clear xfc. &lt;/P&gt;&lt;P&gt;    xfc-fieldname = xdetails-name . &lt;/P&gt;&lt;P&gt;    xfc-datatype = xdetails-type_kind. &lt;/P&gt;&lt;P&gt;    xfc-inttype = xdetails-type_kind. &lt;/P&gt;&lt;P&gt;    xfc-intlen = xdetails-length. &lt;/P&gt;&lt;P&gt;    xfc-decimals = xdetails-decimals. &lt;/P&gt;&lt;P&gt;    append xfc to ifc. &lt;/P&gt;&lt;P&gt;  endloop. &lt;/P&gt;&lt;P&gt;  endform. &lt;/P&gt;&lt;P&gt;  form create_dynamic_itab. &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 = ifc &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;P&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;  endform. &lt;/P&gt;&lt;P&gt;    &lt;/P&gt;&lt;P&gt;  form get_data. &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Select Data from table. &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  select * into table &amp;lt;dyn_table&amp;gt; &lt;/P&gt;&lt;P&gt;             from (p_table). &lt;/P&gt;&lt;P&gt;  endform. &lt;/P&gt;&lt;P&gt;   Write out data from table. &lt;/P&gt;&lt;P&gt;  loop at &amp;lt;dyn_table&amp;gt; into &amp;lt;dyn_wa&amp;gt;. &lt;/P&gt;&lt;P&gt;    do. &lt;/P&gt;&lt;P&gt;      assign component  sy-index   &lt;/P&gt;&lt;P&gt;         of structure &amp;lt;dyn_wa&amp;gt; to &amp;lt;dyn_field&amp;gt;. &lt;/P&gt;&lt;P&gt;      if sy-subrc &amp;lt;&amp;gt; 0. &lt;/P&gt;&lt;P&gt;        exit. &lt;/P&gt;&lt;P&gt;      endif. &lt;/P&gt;&lt;P&gt;      if sy-index = 1. &lt;/P&gt;&lt;P&gt;        write:/ &amp;lt;dyn_field&amp;gt;. &lt;/P&gt;&lt;P&gt;      else. &lt;/P&gt;&lt;P&gt;        write: &amp;lt;dyn_field&amp;gt;. &lt;/P&gt;&lt;P&gt;      endif. &lt;/P&gt;&lt;P&gt;    enddo. &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;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------------------------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT ZCLUST1 . &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Example: how to create a dynamic internal table &lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; &lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;The dynamic internal table stucture &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;DATA: BEGIN OF STRUCT OCCURS 10, &lt;/P&gt;&lt;P&gt;    FILDNAME(8) TYPE C, &lt;/P&gt;&lt;P&gt;    ABPTYPE TYPE C, &lt;/P&gt;&lt;P&gt;    LENGTH TYPE I, &lt;/P&gt;&lt;P&gt;END OF STRUCT. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;The dynamic program source table &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;DATA: BEGIN OF INCTABL OCCURS 10, &lt;/P&gt;&lt;P&gt;    LINE(72), &lt;/P&gt;&lt;P&gt;END OF INCTABL. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: LNG TYPE I, TYPESRTING(6). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Sample dynamic internal table stucture &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;STRUCT-FILDNAME = 'field1'. STRUCT-ABPTYPE = 'c'. STRUCT-LENGTH = '6'. &lt;/P&gt;&lt;P&gt;APPEND STRUCT. CLEAR STRUCT. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;STRUCT-FILDNAME = 'field2'. STRUCT-ABPTYPE = 'd'. &lt;/P&gt;&lt;P&gt;APPEND STRUCT. CLEAR STRUCT. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;STRUCT-FILDNAME = 'field3'. STRUCT-ABPTYPE = 'i'. &lt;/P&gt;&lt;P&gt;APPEND STRUCT. CLEAR STRUCT. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Create the dynamic internal table definition in the dyn. program &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;INCTABL-LINE = 'program zdynpro.'. APPEND INCTABL. &lt;/P&gt;&lt;P&gt;INCTABL-LINE = 'data: begin of dyntab occurs 10,'. APPEND INCTABL. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT STRUCT. &lt;/P&gt;&lt;P&gt;  INCTABL-LINE = STRUCT-FILDNAME. &lt;/P&gt;&lt;P&gt;  LNG = STRLEN( STRUCT-FILDNAME ). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF NOT STRUCT-LENGTH IS INITIAL . &lt;/P&gt;&lt;P&gt;      TYPESRTING(1) = '('. &lt;/P&gt;&lt;P&gt;      TYPESRTING+1 = STRUCT-LENGTH. &lt;/P&gt;&lt;P&gt;      TYPESRTING+5 = ')'. &lt;/P&gt;&lt;P&gt;      CONDENSE TYPESRTING NO-GAPS. &lt;/P&gt;&lt;P&gt;      INCTABL-LINE+LNG = TYPESRTING. &lt;/P&gt;&lt;P&gt;  ENDIF. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  INCTABL-LINE+15 = 'type '. &lt;/P&gt;&lt;P&gt;  INCTABL-LINE+21 = STRUCT-ABPTYPE. &lt;/P&gt;&lt;P&gt;  INCTABL-LINE+22 = ','. &lt;/P&gt;&lt;P&gt;  APPEND INCTABL. &lt;/P&gt;&lt;P&gt;ENDLOOP. &lt;/P&gt;&lt;P&gt;INCTABL-LINE = 'end of dyntab. '. &lt;/P&gt;&lt;P&gt;APPEND INCTABL. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Create the code processes the dynamic internal table &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;INCTABL-LINE = ' '. APPEND INCTABL. &lt;/P&gt;&lt;P&gt;INCTABL-LINE = 'dyntab-field1 = ''aaaaaa''.'. APPEND INCTABL. &lt;/P&gt;&lt;P&gt;INCTABL-LINE = 'dyntab-field1 = ''19970814''.'. APPEND INCTABL. &lt;/P&gt;&lt;P&gt;INCTABL-LINE = 'dyntab-field1 = 1.'. APPEND INCTABL. &lt;/P&gt;&lt;P&gt;INCTABL-LINE = 'append dyntab.'. APPEND INCTABL. &lt;/P&gt;&lt;P&gt;INCTABL-LINE = ' '. APPEND INCTABL. &lt;/P&gt;&lt;P&gt;INCTABL-LINE = 'loop at dyntab.'. APPEND INCTABL. &lt;/P&gt;&lt;P&gt;INCTABL-LINE = 'write: / dyntab.'. APPEND INCTABL. &lt;/P&gt;&lt;P&gt;INCTABL-LINE = 'endloop.'. APPEND INCTABL. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Create and run the dynamic program &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;INSERT REPORT 'zdynpro'(001) FROM INCTABL. &lt;/P&gt;&lt;P&gt;SUBMIT ZDYNPRO. &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;&lt;/P&gt;&lt;P&gt;or Just try out this simpler dynamic internal tables &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: itab TYPE STANDARD TABLE OF spfli, &lt;/P&gt;&lt;P&gt;              wa LIKE LINE OF itab. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: line(72) TYPE c, &lt;/P&gt;&lt;P&gt;            list LIKE TABLE OF line(72). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;START-OF-SELECTION. &lt;/P&gt;&lt;P&gt;*line = ' CITYFROM CITYTO '. &lt;/P&gt;&lt;P&gt;  line = ' AIRPTO '. &lt;/P&gt;&lt;P&gt; APPEND line TO list. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT DISTINCT (list) &lt;/P&gt;&lt;P&gt;       INTO CORRESPONDING FIELDS OF TABLE itab &lt;/P&gt;&lt;P&gt;            FROM spfli. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF sy-subrc EQ 0. &lt;/P&gt;&lt;P&gt;  LOOP AT itab INTO wa. &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    WRITE: / wa-cityfrom, wa-cityto. &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;       WRITE &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt; wa-airpto. &lt;/P&gt;&lt;P&gt;  ENDLOOP. &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;STRONG&gt;&amp;lt;REMOVED BY MODERATOR&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Alvaro Tejada Galindo on Feb 14, 2008 2:10 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Feb 2008 10:36:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/creating-dynamic-internal-table/m-p/3427964#M823336</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-14T10:36:35Z</dc:date>
    </item>
    <item>
      <title>Re: Creating dynamic internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/creating-dynamic-internal-table/m-p/3427965#M823337</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi JuzMe,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;what you tried may not work; if not syntax than run time error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Must be like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your input field is of TYPE tabname.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then it will be&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data:
  lr_tab type ref to data.
field-symbols:
  &amp;lt;tab&amp;gt; type standard table.
create data lr_tab type table of (IO_TABLE).
assign lr_tab-&amp;gt;* to &amp;lt;tab&amp;gt;.
SELECT * 
  INTO TABLE &amp;lt;tab&amp;gt;
  FROM (IO_TABLE)
  WHERE ...
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But this is just dynamic data. I'd call it a dynamic table if the fields do not come from an existing structure, i.e. if you add or remove some fields from a structure at runtime and create a table from that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Clemens&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Feb 2008 20:02:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/creating-dynamic-internal-table/m-p/3427965#M823337</guid>
      <dc:creator>Clemenss</dc:creator>
      <dc:date>2008-02-14T20:02:08Z</dc:date>
    </item>
  </channel>
</rss>

