<?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 Internal table Creation dynamically in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-creation-dynamically/m-p/4273290#M1019568</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please help me to create an internal table dynamically&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Thanks,&lt;/P&gt;&lt;P&gt;Ramakrishna&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 02 Aug 2008 05:51:57 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-08-02T05:51:57Z</dc:date>
    <item>
      <title>Internal table Creation dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-creation-dynamically/m-p/4273290#M1019568</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please help me to create an internal table dynamically&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Thanks,&lt;/P&gt;&lt;P&gt;Ramakrishna&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 02 Aug 2008 05:51:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-creation-dynamically/m-p/4273290#M1019568</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-08-02T05:51:57Z</dc:date>
    </item>
    <item>
      <title>Re: Internal table Creation dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-creation-dynamically/m-p/4273291#M1019569</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|http://www.sap-img.com/ab030.htm]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[SDN thread|&lt;A class="jive_macro jive_macro_message" href="https://community.sap.com/" __jive_macro_name="message" modifiedtitle="true" __default_attr="5349953"&gt;&lt;/A&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;Pavan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 02 Aug 2008 05:53:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-creation-dynamically/m-p/4273291#M1019569</guid>
      <dc:creator>bpawanchand</dc:creator>
      <dc:date>2008-08-02T05:53:58Z</dc:date>
    </item>
    <item>
      <title>Re: Internal table Creation dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-creation-dynamically/m-p/4273292#M1019570</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1.First Get the components from the table(fields) "if you are using the Table&lt;/P&gt;&lt;P&gt;2.Create the fieldcatalog " or else manually create the fieldcat&lt;/P&gt;&lt;P&gt;3.Create the Dynamic Table using the CL_ALV_TABLE_CREATE&lt;/P&gt;&lt;P&gt;4. Now use the select&lt;/P&gt;&lt;P&gt;5. Display the data&lt;/P&gt;&lt;P&gt;Check the sample code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT  ytest_dynamic.
 
TYPE-POOLS : abap.
DATA : table_des TYPE REF TO cl_abap_structdescr.
DATA : ifields TYPE abap_compdescr_tab,
          wa_field LIKE LINE OF ifields.
DATA: it_fieldcat TYPE lvc_t_fcat,
          wa_fieldcat TYPE lvc_s_fcat.
DATA: i_tab TYPE REF TO data.
 
FIELD-SYMBOLS: &amp;lt;fs&amp;gt; TYPE STANDARD TABLE.
 
PARAMETERS: p_table(30) TYPE c DEFAULT 'SFLIGHT'.
 
 
"Table definiton using the table name
table_des ?= cl_abap_typedescr=&amp;gt;describe_by_name( p_table ).
"Now Read all the fields to a table.
ifields = table_des-&amp;gt;components.
 
 
LOOP AT ifields INTO wa_field.
  CLEAR wa_fieldcat.
  wa_fieldcat-fieldname = wa_field-name .
  wa_fieldcat-datatype = wa_field-type_kind.
  wa_fieldcat-inttype = wa_field-type_kind.
  wa_fieldcat-intlen = wa_field-length.
  wa_fieldcat-decimals = wa_field-decimals.
  wa_fieldcat-coltext = wa_field-name.
  wa_fieldcat-outputlen = wa_field-length.
 
  APPEND  wa_fieldcat TO it_fieldcat.
ENDLOOP.
 
CALL METHOD cl_alv_table_create=&amp;gt;create_dynamic_table
  EXPORTING
    it_fieldcatalog           = it_fieldcat
  IMPORTING
    ep_table                  = i_tab
*    e_style_fname             =
  EXCEPTIONS
    generate_subpool_dir_full = 1
    OTHERS                    = 2
        .
IF sy-subrc ne  0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
 
ASSIGN i_tab-&amp;gt;* TO &amp;lt;fs&amp;gt;.
 
*-fill the data
APPEND INITIAL LINE TO &amp;lt;fs&amp;gt;.
 
SELECT  *
INTO TABLE &amp;lt;fs&amp;gt;
FROM (p_table)
UP TO 20 ROWS.
 
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
  EXPORTING
    i_callback_program = sy-repid
    it_fieldcat_lvc    = it_fieldcat
  TABLES
    t_outtab           = &amp;lt;fs&amp;gt;
  EXCEPTIONS
    program_error      = 1
    OTHERS             = 2.
IF sy-subrc ne  0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 02 Aug 2008 05:55:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-creation-dynamically/m-p/4273292#M1019570</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-08-02T05:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: Internal table Creation dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-creation-dynamically/m-p/4273293#M1019571</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;&lt;/P&gt;&lt;P&gt;REPORT  Zgen .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;type-pools : abap.&lt;/P&gt;&lt;P&gt;&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;&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;&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 .&lt;/P&gt;&lt;P&gt;selection-screen end of block b1.&lt;/P&gt;&lt;P&gt;&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;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Form  get_structure&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&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;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.                    "get_structure&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Form  create_dynamic_itab&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form create_dynamic_itab.&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;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.                    "create_dynamic_itab&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Form  get_data&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form get_data.&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.                    "get_data&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  Write out data from table.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;***&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Form  write_out&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; --&amp;gt;  p1        text&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; &amp;lt;--  p2        text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM write_out .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CALL FUNCTION 'WS_DOWNLOAD'&lt;/P&gt;&lt;P&gt;    EXPORTING&lt;/P&gt;&lt;P&gt;      codepage                = 'IBM'&lt;/P&gt;&lt;P&gt;      filename                = 'C:\Documents and Settings\gp1104\Desktop\TEST\test.txt'&lt;/P&gt;&lt;P&gt;      filetype                = 'DAT'&lt;/P&gt;&lt;P&gt;    TABLES&lt;/P&gt;&lt;P&gt;      data_tab                = &amp;lt;dyn_table&amp;gt;&lt;/P&gt;&lt;P&gt;    EXCEPTIONS&lt;/P&gt;&lt;P&gt;      FILE_OPEN_ERROR         = 1&lt;/P&gt;&lt;P&gt;      FILE_WRITE_ERROR        = 2&lt;/P&gt;&lt;P&gt;      INVALID_FILESIZE        = 3&lt;/P&gt;&lt;P&gt;      INVALID_TYPE            = 4&lt;/P&gt;&lt;P&gt;      NO_BATCH                = 5&lt;/P&gt;&lt;P&gt;      UNKNOWN_ERROR           = 6&lt;/P&gt;&lt;P&gt;      INVALID_TABLE_WIDTH     = 7&lt;/P&gt;&lt;P&gt;      GUI_REFUSE_FILETRANSFER = 8&lt;/P&gt;&lt;P&gt;      CUSTOMER_ERROR          = 9&lt;/P&gt;&lt;P&gt;      NO_AUTHORITY            = 10&lt;/P&gt;&lt;P&gt;      OTHERS                  = 11.&lt;/P&gt;&lt;P&gt;  IF SY-SUBRC &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO&lt;/P&gt;&lt;P&gt;            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDFORM.                    " write_out&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rgds,&lt;/P&gt;&lt;P&gt;Paras&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 02 Aug 2008 05:56:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-creation-dynamically/m-p/4273293#M1019571</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-08-02T05:56:27Z</dc:date>
    </item>
    <item>
      <title>Re: Internal table Creation dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-creation-dynamically/m-p/4273294#M1019572</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;See the example program on how to create Dynamic IT :&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.
  perform create_dynamic_itab.      **********Creates a dyanamic internal table**********
  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.

REPORT ZCLUST1 .
*
* Example: how to create a dynamic internal table
* 
* The dynamic internal table stucture
DATA: BEGIN OF STRUCT OCCURS 10,
    FILDNAME(8) TYPE C,
    ABPTYPE TYPE C,
    LENGTH TYPE I,
END OF STRUCT.

* The dynamic program source table
DATA: BEGIN OF INCTABL OCCURS 10,
    LINE(72),
END OF INCTABL.

DATA: LNG TYPE I, TYPESRTING(6).

* Sample dynamic internal table stucture
STRUCT-FILDNAME = 'field1'. STRUCT-ABPTYPE = 'c'. STRUCT-LENGTH = '6'.
APPEND STRUCT. CLEAR STRUCT.

STRUCT-FILDNAME = 'field2'. STRUCT-ABPTYPE = 'd'.
APPEND STRUCT. CLEAR STRUCT.

STRUCT-FILDNAME = 'field3'. STRUCT-ABPTYPE = 'i'.
APPEND STRUCT. CLEAR STRUCT.

* Create the dynamic internal table definition in the dyn. program
INCTABL-LINE = 'program zdynpro.'. APPEND INCTABL.
INCTABL-LINE = 'data: begin of dyntab occurs 10,'. APPEND INCTABL.

LOOP AT STRUCT.
  INCTABL-LINE = STRUCT-FILDNAME.
  LNG = STRLEN( STRUCT-FILDNAME ).

  IF NOT STRUCT-LENGTH IS INITIAL .
      TYPESRTING(1) = '('.
      TYPESRTING+1 = STRUCT-LENGTH.
      TYPESRTING+5 = ')'.
      CONDENSE TYPESRTING NO-GAPS.
      INCTABL-LINE+LNG = TYPESRTING.
  ENDIF.

  INCTABL-LINE+15 = 'type '.
  INCTABL-LINE+21 = STRUCT-ABPTYPE.
  INCTABL-LINE+22 = ','.
  APPEND INCTABL.
ENDLOOP.
INCTABL-LINE = 'end of dyntab. '.
APPEND INCTABL.

* Create the code processes the dynamic internal table
INCTABL-LINE = ' '. APPEND INCTABL.
INCTABL-LINE = 'dyntab-field1 = ''aaaaaa''.'. APPEND INCTABL.
INCTABL-LINE = 'dyntab-field1 = ''19970814''.'. APPEND INCTABL.
INCTABL-LINE = 'dyntab-field1 = 1.'. APPEND INCTABL.
INCTABL-LINE = 'append dyntab.'. APPEND INCTABL.
INCTABL-LINE = ' '. APPEND INCTABL.
INCTABL-LINE = 'loop at dyntab.'. APPEND INCTABL.
INCTABL-LINE = 'write: / dyntab.'. APPEND INCTABL.
INCTABL-LINE = 'endloop.'. APPEND INCTABL.

* Create and run the dynamic program
INSERT REPORT 'zdynpro'(001) FROM INCTABL.
SUBMIT ZDYNPRO.

or Just try out this simpler dynamic internal tables

DATA: itab TYPE STANDARD TABLE OF spfli,
              wa LIKE LINE OF itab.

DATA: line(72) TYPE c,
            list LIKE TABLE OF line(72).

START-OF-SELECTION.
*line = ' CITYFROM CITYTO '.
  line = ' AIRPTO '.
 APPEND line TO list.

SELECT DISTINCT (list)
       INTO CORRESPONDING FIELDS OF TABLE itab
            FROM spfli.

IF sy-subrc EQ 0.
  LOOP AT itab INTO wa.
*     WRITE: / wa-cityfrom, wa-cityto.
       WRITE :/ wa-airpto.
  ENDLOOP.
ENDIF. &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 02 Aug 2008 05:57:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-creation-dynamically/m-p/4273294#M1019572</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-08-02T05:57:45Z</dc:date>
    </item>
    <item>
      <title>Re: Internal table Creation dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-creation-dynamically/m-p/4273295#M1019573</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;refer to the sample code below for dynamic creation of internal table:&lt;/P&gt;&lt;P&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;With luck,&lt;/P&gt;&lt;P&gt;Pritam.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 02 Aug 2008 06:02:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-creation-dynamically/m-p/4273295#M1019573</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-08-02T06:02:36Z</dc:date>
    </item>
    <item>
      <title>Re: Internal table Creation dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-creation-dynamically/m-p/4273296#M1019574</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ramakrishna.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to suggest a couple of references,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[SDN Wiki Code Gallery - Standard Reference for Creating Internal Table dynamically and displaying it as ALV with header and footer text|https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/dynamic%2binternal%2btable]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[SDN Weblog Code Gallery - Standard Reference for Dynamic Internal Tables and Structures - ABAP|https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/2071] &lt;B&gt;[original link is broken]&lt;/B&gt; &lt;B&gt;[original link is broken]&lt;/B&gt; &lt;B&gt;[original link is broken]&lt;/B&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that's usefull.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good Luck &amp;amp; Regards.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Harsh Dave&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 02 Aug 2008 06:17:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-creation-dynamically/m-p/4273296#M1019574</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-08-02T06:17:22Z</dc:date>
    </item>
    <item>
      <title>Re: Internal table Creation dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-creation-dynamically/m-p/4273297#M1019575</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;RR,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[Blog of Rich (King Of Abap)|https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/2071] &lt;B&gt;[original link is broken]&lt;/B&gt; &lt;B&gt;[original link is broken]&lt;/B&gt; &lt;B&gt;[original link is broken]&lt;/B&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Amit.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 02 Aug 2008 13:00:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-creation-dynamically/m-p/4273297#M1019575</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-08-02T13:00:09Z</dc:date>
    </item>
    <item>
      <title>Re: Internal table Creation dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-creation-dynamically/m-p/4273298#M1019576</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It depends on exactly what you mean by creation of internal tables dynamically.  The following example is taken from part of a program that I did for dynamically populating various DB tables using generic internal tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
Data:
l_UploadData type ref to data.

create data l_UploadData type standard table of (l_TableName).

assign l_UploadData-&amp;gt;* to &amp;lt;UploadData&amp;gt;.


CALL METHOD CL_GUI_FRONTEND_SERVICES=&amp;gt;GUI_UPLOAD
EXPORTING
        FILENAME = l_FileName
        HAS_FIELD_SEPARATOR = 'X'
CHANGING
        DATA_TAB = &amp;lt;UploadData&amp;gt;
EXCEPTIONS
        others = 1.

if ( not l_Parameters-Mode-Insert is initial ).
	Insert (l_Parameters-TableName) from table &amp;lt;UploadData&amp;gt;.
elseif ( not l_Parameters-Mode-Update is initial ).
	Update (l_Parameters-TableName) from table &amp;lt;UploadData&amp;gt;.
elseif ( not l_Parameters-Mode-Modify is initial ).
	Modify (l_Parameters-TableName) from table &amp;lt;UploadData&amp;gt;.
elseif ( not l_Parameters-Mode-delete is initial ).
	Delete (l_Parameters-TableName) from table &amp;lt;UploadData&amp;gt;.
endif.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;~Ian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 02 Aug 2008 20:17:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-creation-dynamically/m-p/4273298#M1019576</guid>
      <dc:creator>ian_maxwell2</dc:creator>
      <dc:date>2008-08-02T20:17:11Z</dc:date>
    </item>
  </channel>
</rss>

