<?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 tables dynamically in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-tables-dynamically/m-p/4134910#M988848</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Lee,&lt;/P&gt;&lt;P&gt;      Better follow this code I have tested this it is better written than the previous one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;type-pools: slis.&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;&lt;/P&gt;&lt;P&gt;data: alv_fldcat type slis_t_fieldcat_alv,&lt;/P&gt;&lt;P&gt;it_fldcat type lvc_t_fcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;selection-screen begin of block b1 with frame title text-001.&lt;/P&gt;&lt;P&gt;parameters: p_flds(5) 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;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*build the dynamic internal table&lt;/P&gt;&lt;P&gt;perform build_dyn_itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*write 5 records to the alv grid&lt;/P&gt;&lt;P&gt;do 5 times.&lt;/P&gt;&lt;P&gt;perform build_report.&lt;/P&gt;&lt;P&gt;enddo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*call the alv grid.&lt;/P&gt;&lt;P&gt;perform call_alv.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;P&gt;*Build_dyn_itab&lt;/P&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;P&gt;form build_dyn_itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: new_table type ref to data,&lt;/P&gt;&lt;P&gt;new_line type ref to data,&lt;/P&gt;&lt;P&gt;wa_it_fldcat type lvc_s_fcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Create fields .&lt;/P&gt;&lt;P&gt;clear wa_it_fldcat.&lt;/P&gt;&lt;P&gt;wa_it_fldcat-fieldname = 'name1'.&lt;/P&gt;&lt;P&gt;wa_it_fldcat-datatype = 'mara-matnr'.&lt;/P&gt;&lt;P&gt;wa_it_fldcat-intlen = 5.&lt;/P&gt;&lt;P&gt;append wa_it_fldcat to it_fldcat .&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;*clear wa_it_fldcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;wa_it_fldcat-fieldname = sy-index.&lt;/P&gt;&lt;P&gt;wa_it_fldcat-datatype = 'CHAR'.&lt;/P&gt;&lt;P&gt;wa_it_fldcat-intlen = 5.&lt;/P&gt;&lt;P&gt;append wa_it_fldcat to it_fldcat .&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do p_flds times.&lt;/P&gt;&lt;P&gt;clear wa_it_fldcat.&lt;/P&gt;&lt;P&gt;wa_it_fldcat-fieldname = sy-index.&lt;/P&gt;&lt;P&gt;wa_it_fldcat-datatype = 'CHAR'.&lt;/P&gt;&lt;P&gt;wa_it_fldcat-intlen = 6.&lt;/P&gt;&lt;P&gt;append wa_it_fldcat to it_fldcat .&lt;/P&gt;&lt;P&gt;enddo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Create dynamic internal table and assign to FS&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 = it_fldcat&lt;/P&gt;&lt;P&gt;importing&lt;/P&gt;&lt;P&gt;ep_table = new_table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;assign new_table-&amp;gt;* to &amp;lt;dyn_table&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Create dynamic work area and assign to FS&lt;/P&gt;&lt;P&gt;create data new_line like line of &amp;lt;dyn_table&amp;gt;.&lt;/P&gt;&lt;P&gt;assign new_line-&amp;gt;* to &amp;lt;dyn_wa&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*********************************************************************&lt;/P&gt;&lt;P&gt;*Form build_report&lt;/P&gt;&lt;P&gt;*********************************************************************&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form build_report.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: fieldname(20) type c.&lt;/P&gt;&lt;P&gt;data: fieldvalue(5) type c.&lt;/P&gt;&lt;P&gt;data: index(3) type c.&lt;/P&gt;&lt;P&gt;field-symbols: &amp;lt;fs1&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do p_flds times.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;index = sy-index.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Set up fieldvalue&lt;/P&gt;&lt;P&gt;concatenate 'FLD' index into&lt;/P&gt;&lt;P&gt;fieldvalue.&lt;/P&gt;&lt;P&gt;condense fieldvalue no-gaps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;assign component index of structure &amp;lt;dyn_wa&amp;gt; to &amp;lt;fs1&amp;gt;.&lt;/P&gt;&lt;P&gt;&amp;lt;fs1&amp;gt; = fieldvalue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;enddo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Append to the dynamic internal table&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;&lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;P&gt;*CALL_ALV&lt;/P&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;P&gt;form call_alv.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: wa_cat like line of alv_fldcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*clear wa_cat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;wa_cat-fieldname = 'matnr'.&lt;/P&gt;&lt;P&gt;wa_cat-seltext_s = sy-index.&lt;/P&gt;&lt;P&gt;wa_cat-outputlen = '10'.&lt;/P&gt;&lt;P&gt;append wa_cat to alv_fldcat.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do p_flds times.&lt;/P&gt;&lt;P&gt;clear wa_cat.&lt;/P&gt;&lt;P&gt;wa_cat-fieldname = sy-index.&lt;/P&gt;&lt;P&gt;wa_cat-seltext_s = sy-index.&lt;/P&gt;&lt;P&gt;wa_cat-outputlen = '6'.&lt;/P&gt;&lt;P&gt;append wa_cat to alv_fldcat.&lt;/P&gt;&lt;P&gt;enddo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Call ABAP List Viewer (ALV)&lt;/P&gt;&lt;P&gt;call function 'REUSE_ALV_GRID_DISPLAY'&lt;/P&gt;&lt;P&gt;exporting&lt;/P&gt;&lt;P&gt;it_fieldcat = alv_fldcat&lt;/P&gt;&lt;P&gt;tables&lt;/P&gt;&lt;P&gt;t_outtab = &amp;lt;dyn_table&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ram.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 04 Jul 2008 08:34:43 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-07-04T08:34:43Z</dc:date>
    <item>
      <title>Create tables dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-tables-dynamically/m-p/4134901#M988839</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;I need to create a number of tables (with the same number of fields for each table) depending on my data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;E.g. If I input 6 at the selection screen,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to create GT_1, GT_2.... GT_6 with LINE1 TYPE C and LINE2 TYPE C as the fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to do that? Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Janet&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Jul 2008 07:05:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-tables-dynamically/m-p/4134901#M988839</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-04T07:05:13Z</dc:date>
    </item>
    <item>
      <title>Re: Create tables dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-tables-dynamically/m-p/4134902#M988840</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 the tables dynamically we can use the FIELD SYMBOLS.&lt;/P&gt;&lt;P&gt;Where we can assgin the table type ANY type etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pls read more help on FieldSymbols.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There you can find the dynamic creation of tables.&lt;/P&gt;&lt;P&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;Chandralekha.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Craig Cmehil on Jul 4, 2008 10:31 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Jul 2008 07:10:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-tables-dynamically/m-p/4134902#M988840</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-04T07:10:28Z</dc:date>
    </item>
    <item>
      <title>Re: Create tables dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-tables-dynamically/m-p/4134903#M988841</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Check this link: [http://www.sap-img.com/ab030.htm|http://www.sap-img.com/ab030.htm]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Pole&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Pole li on Jul 4, 2008 9:11 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Jul 2008 07:10:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-tables-dynamically/m-p/4134903#M988841</guid>
      <dc:creator>pole_li</dc:creator>
      <dc:date>2008-07-04T07:10:59Z</dc:date>
    </item>
    <item>
      <title>Re: Create tables dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-tables-dynamically/m-p/4134904#M988842</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Janet&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is a sample code to create an internal table dynamically.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TYPE-POOLS:
  abap.
 
DATA:
  gr_structdescr    TYPE REF TO cl_abap_structdescr,
  gr_tabledescr     TYPE REF TO cl_abap_tabledescr,
  gt_components     TYPE abap_component_tab,
  gw_component      TYPE LINE OF abap_component_tab,
  gt_keys           TYPE abap_keydescr_tab,
  gw_key            TYPE LINE OF abap_keydescr_tab,
  gr_wa             TYPE REF TO data,
  gr_itab           TYPE REF TO data.
 
 
FIELD-SYMBOLS:
  &amp;lt;gw_wa&amp;gt;           TYPE ANY,
  &amp;lt;gt_itab&amp;gt;         TYPE ANY TABLE.
 
 
START-OF-SELECTION.
 
* determine components of structure -&amp;gt; GT_COMPONENTS
  MOVE 'COMP1' TO gw_component-name.
  gw_component-type ?= cl_abap_elemdescr=&amp;gt;get_string( ).
  INSERT gw_component INTO TABLE gt_components.
 
  MOVE 'COMP2' TO gw_component-name.
  gw_component-type ?= cl_abap_elemdescr=&amp;gt;get_i( ).
  INSERT gw_component INTO TABLE gt_components.
 
 
* get structure descriptor -&amp;gt; GR_STRUCTDESCR
  gr_structdescr ?= cl_abap_structdescr=&amp;gt;create( gt_components ).
 
 
* create work area of structure GR_STRUCTDESCR -&amp;gt; GR_WA
  CREATE DATA gr_wa TYPE HANDLE gr_structdescr.
 
  ASSIGN gr_wa-&amp;gt;* TO &amp;lt;gw_wa&amp;gt;.
 
 
* determine key components -&amp;gt; GT_KEYS
  MOVE 'COMP1' TO gw_key-name.
  INSERT gw_key INTO TABLE gt_keys.
 
 
* create descriptor for internal table -&amp;gt; GR_TABLEDESCR
  gr_tabledescr ?= cl_abap_tabledescr=&amp;gt;create( p_line_type  = gr_structdescr
                                               p_table_kind = cl_abap_tabledescr=&amp;gt;tablekind_hashed
                                               p_unique     = abap_true
                                               p_key        = gt_keys
                                               p_key_kind   = cl_abap_tabledescr=&amp;gt;keydefkind_user ).
 
 
* create internal table -&amp;gt; GR_ITAB
  CREATE DATA gr_itab TYPE HANDLE gr_tabledescr.
 
  ASSIGN gr_itab-&amp;gt;* TO &amp;lt;gt_itab&amp;gt;.
 
  sy-subrc = sy-subrc.&lt;/CODE&gt;&lt;/PRE&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;Regards&lt;/P&gt;&lt;P&gt;Anup.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Jul 2008 07:15:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-tables-dynamically/m-p/4134904#M988842</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-04T07:15:02Z</dc:date>
    </item>
    <item>
      <title>Re: Create tables dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-tables-dynamically/m-p/4134905#M988843</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 you please elaborate your question.&lt;/P&gt;&lt;P&gt;do you want to create dynamic internal tables or database tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For these two the approach is different.&lt;/P&gt;&lt;P&gt;In my earlier post that was the way to create internal tables.&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;Regards&lt;/P&gt;&lt;P&gt;Chandralekha.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Craig Cmehil on Jul 4, 2008 10:31 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Jul 2008 07:16:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-tables-dynamically/m-p/4134905#M988843</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-04T07:16:34Z</dc:date>
    </item>
    <item>
      <title>Re: Create tables dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-tables-dynamically/m-p/4134906#M988844</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;/P&gt;&lt;P&gt;Please check this link&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;STRONG&gt;Dynamic Internal Table&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.saptechnical.com/Tutorials/ABAP/DynamicInternaltable/DynamicInternalTable.htm" target="test_blank"&gt;http://www.saptechnical.com/Tutorials/ABAP/DynamicInternaltable/DynamicInternalTable.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;raam&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Jul 2008 07:17:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-tables-dynamically/m-p/4134906#M988844</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-04T07:17:48Z</dc:date>
    </item>
    <item>
      <title>Re: Create tables dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-tables-dynamically/m-p/4134907#M988845</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Janet - please use the search functionality.  This question has been asked time and again.  There's plenty of information available and you'll find it quicker than posting a question.  It is also part of the rules here to search first, ask second.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Jul 2008 07:18:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-tables-dynamically/m-p/4134907#M988845</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2008-07-04T07:18:57Z</dc:date>
    </item>
    <item>
      <title>Re: Create tables dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-tables-dynamically/m-p/4134908#M988846</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the replies. Most of the replies I managed to find from the old forums. However I am not too sure on how to implement this to my problem. Maybe it is because I am not too sure on how to use field symbols and field symbols need to be define first. But I will not know how many field symbol to define until runtime.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway I will check again and assign points again. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Janet&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Jul 2008 07:28:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-tables-dynamically/m-p/4134908#M988846</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-04T07:28:22Z</dc:date>
    </item>
    <item>
      <title>Re: Create tables dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-tables-dynamically/m-p/4134909#M988847</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Check the following code it is very similar to your requirment.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;type-pools: slis.&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;&lt;/P&gt;&lt;P&gt;data: alv_fldcat type slis_t_fieldcat_alv,&lt;/P&gt;&lt;P&gt;it_fldcat type lvc_t_fcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;selection-screen begin of block b1 with frame title text-001.&lt;/P&gt;&lt;P&gt;parameters: p_flds(5) 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;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;build the dynamic internal table &lt;/P&gt;&lt;P&gt;perform build_dyn_itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;write 5 records to the alv grid &lt;/P&gt;&lt;P&gt;do 5 times.&lt;/P&gt;&lt;P&gt;perform build_report.&lt;/P&gt;&lt;P&gt;enddo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;call the alv grid. &lt;/P&gt;&lt;P&gt;perform call_alv.&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;Build_dyn_itab &lt;/P&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;P&gt;form build_dyn_itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: new_table type ref to data,&lt;/P&gt;&lt;P&gt;new_line type ref to data,&lt;/P&gt;&lt;P&gt;wa_it_fldcat type lvc_s_fcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Create fields . &lt;/P&gt;&lt;P&gt;clear wa_it_fldcat. &lt;/P&gt;&lt;P&gt;wa_it_fldcat-fieldname = name1. &lt;/P&gt;&lt;P&gt;wa_it_fldcat-datatype = 'mara-matnr'. &lt;/P&gt;&lt;P&gt;wa_it_fldcat-intlen = 5. &lt;/P&gt;&lt;P&gt;append wa_it_fldcat to it_fldcat . &lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;*clear wa_it_fldcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;wa_it_fldcat-fieldname = sy-index. &lt;/P&gt;&lt;P&gt;wa_it_fldcat-datatype = 'CHAR'. &lt;/P&gt;&lt;P&gt;wa_it_fldcat-intlen = 5. &lt;/P&gt;&lt;P&gt;append wa_it_fldcat to it_fldcat . &lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do p_flds times.&lt;/P&gt;&lt;P&gt;clear wa_it_fldcat.&lt;/P&gt;&lt;P&gt;wa_it_fldcat-fieldname = sy-index.&lt;/P&gt;&lt;P&gt;wa_it_fldcat-datatype = 'CHAR'.&lt;/P&gt;&lt;P&gt;wa_it_fldcat-intlen = 6.&lt;/P&gt;&lt;P&gt;append wa_it_fldcat to it_fldcat .&lt;/P&gt;&lt;P&gt;enddo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Create dynamic internal table and assign to FS &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 = it_fldcat&lt;/P&gt;&lt;P&gt;importing&lt;/P&gt;&lt;P&gt;ep_table = new_table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;assign new_table-&amp;gt;* to &amp;lt;dyn_table&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Create dynamic work area and assign to FS &lt;/P&gt;&lt;P&gt;create data new_line like line of &amp;lt;dyn_table&amp;gt;.&lt;/P&gt;&lt;P&gt;assign new_line-&amp;gt;* to &amp;lt;dyn_wa&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*********************************************************************&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Form build_report &lt;/P&gt;&lt;P&gt;*********************************************************************&lt;/P&gt;&lt;P&gt;form build_report.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: fieldname(20) type c.&lt;/P&gt;&lt;P&gt;data: fieldvalue(5) type c.&lt;/P&gt;&lt;P&gt;data: index(3) type c.&lt;/P&gt;&lt;P&gt;field-symbols: &amp;lt;fs1&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do p_flds times.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;index = sy-index.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Set up fieldvalue &lt;/P&gt;&lt;P&gt;concatenate 'FLD' index into&lt;/P&gt;&lt;P&gt;fieldvalue.&lt;/P&gt;&lt;P&gt;condense fieldvalue no-gaps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;assign component index of structure &amp;lt;dyn_wa&amp;gt; to &amp;lt;fs1&amp;gt;.&lt;/P&gt;&lt;P&gt;&amp;lt;fs1&amp;gt; = fieldvalue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;enddo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Append to the dynamic internal table &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;&lt;/P&gt;&lt;P&gt;endform.&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;CALL_ALV &lt;/P&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;P&gt;form call_alv.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: wa_cat like line of alv_fldcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*clear wa_cat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;wa_cat-fieldname = matnr. &lt;/P&gt;&lt;P&gt;wa_cat-seltext_s = sy-index. &lt;/P&gt;&lt;P&gt;wa_cat-outputlen = 'ma'. &lt;/P&gt;&lt;P&gt;append wa_cat to alv_fldcat. &lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do p_flds times.&lt;/P&gt;&lt;P&gt;clear wa_cat.&lt;/P&gt;&lt;P&gt;wa_cat-fieldname = sy-index.&lt;/P&gt;&lt;P&gt;wa_cat-seltext_s = sy-index.&lt;/P&gt;&lt;P&gt;wa_cat-outputlen = '6'.&lt;/P&gt;&lt;P&gt;append wa_cat to alv_fldcat.&lt;/P&gt;&lt;P&gt;enddo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Call ABAP List Viewer (ALV) &lt;/P&gt;&lt;P&gt;call function 'REUSE_ALV_GRID_DISPLAY'&lt;/P&gt;&lt;P&gt;exporting&lt;/P&gt;&lt;P&gt;it_fieldcat = alv_fldcat&lt;/P&gt;&lt;P&gt;tables&lt;/P&gt;&lt;P&gt;t_outtab = &amp;lt;dyn_table&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;P&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;Ram.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Craig Cmehil on Jul 7, 2008 9:08 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Jul 2008 07:56:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-tables-dynamically/m-p/4134909#M988847</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-04T07:56:47Z</dc:date>
    </item>
    <item>
      <title>Re: Create tables dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-tables-dynamically/m-p/4134910#M988848</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Lee,&lt;/P&gt;&lt;P&gt;      Better follow this code I have tested this it is better written than the previous one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;type-pools: slis.&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;&lt;/P&gt;&lt;P&gt;data: alv_fldcat type slis_t_fieldcat_alv,&lt;/P&gt;&lt;P&gt;it_fldcat type lvc_t_fcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;selection-screen begin of block b1 with frame title text-001.&lt;/P&gt;&lt;P&gt;parameters: p_flds(5) 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;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*build the dynamic internal table&lt;/P&gt;&lt;P&gt;perform build_dyn_itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*write 5 records to the alv grid&lt;/P&gt;&lt;P&gt;do 5 times.&lt;/P&gt;&lt;P&gt;perform build_report.&lt;/P&gt;&lt;P&gt;enddo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*call the alv grid.&lt;/P&gt;&lt;P&gt;perform call_alv.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;P&gt;*Build_dyn_itab&lt;/P&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;P&gt;form build_dyn_itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: new_table type ref to data,&lt;/P&gt;&lt;P&gt;new_line type ref to data,&lt;/P&gt;&lt;P&gt;wa_it_fldcat type lvc_s_fcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Create fields .&lt;/P&gt;&lt;P&gt;clear wa_it_fldcat.&lt;/P&gt;&lt;P&gt;wa_it_fldcat-fieldname = 'name1'.&lt;/P&gt;&lt;P&gt;wa_it_fldcat-datatype = 'mara-matnr'.&lt;/P&gt;&lt;P&gt;wa_it_fldcat-intlen = 5.&lt;/P&gt;&lt;P&gt;append wa_it_fldcat to it_fldcat .&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;*clear wa_it_fldcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;wa_it_fldcat-fieldname = sy-index.&lt;/P&gt;&lt;P&gt;wa_it_fldcat-datatype = 'CHAR'.&lt;/P&gt;&lt;P&gt;wa_it_fldcat-intlen = 5.&lt;/P&gt;&lt;P&gt;append wa_it_fldcat to it_fldcat .&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do p_flds times.&lt;/P&gt;&lt;P&gt;clear wa_it_fldcat.&lt;/P&gt;&lt;P&gt;wa_it_fldcat-fieldname = sy-index.&lt;/P&gt;&lt;P&gt;wa_it_fldcat-datatype = 'CHAR'.&lt;/P&gt;&lt;P&gt;wa_it_fldcat-intlen = 6.&lt;/P&gt;&lt;P&gt;append wa_it_fldcat to it_fldcat .&lt;/P&gt;&lt;P&gt;enddo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Create dynamic internal table and assign to FS&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 = it_fldcat&lt;/P&gt;&lt;P&gt;importing&lt;/P&gt;&lt;P&gt;ep_table = new_table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;assign new_table-&amp;gt;* to &amp;lt;dyn_table&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Create dynamic work area and assign to FS&lt;/P&gt;&lt;P&gt;create data new_line like line of &amp;lt;dyn_table&amp;gt;.&lt;/P&gt;&lt;P&gt;assign new_line-&amp;gt;* to &amp;lt;dyn_wa&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*********************************************************************&lt;/P&gt;&lt;P&gt;*Form build_report&lt;/P&gt;&lt;P&gt;*********************************************************************&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form build_report.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: fieldname(20) type c.&lt;/P&gt;&lt;P&gt;data: fieldvalue(5) type c.&lt;/P&gt;&lt;P&gt;data: index(3) type c.&lt;/P&gt;&lt;P&gt;field-symbols: &amp;lt;fs1&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do p_flds times.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;index = sy-index.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Set up fieldvalue&lt;/P&gt;&lt;P&gt;concatenate 'FLD' index into&lt;/P&gt;&lt;P&gt;fieldvalue.&lt;/P&gt;&lt;P&gt;condense fieldvalue no-gaps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;assign component index of structure &amp;lt;dyn_wa&amp;gt; to &amp;lt;fs1&amp;gt;.&lt;/P&gt;&lt;P&gt;&amp;lt;fs1&amp;gt; = fieldvalue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;enddo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Append to the dynamic internal table&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;&lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;P&gt;*CALL_ALV&lt;/P&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;P&gt;form call_alv.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: wa_cat like line of alv_fldcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*clear wa_cat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;wa_cat-fieldname = 'matnr'.&lt;/P&gt;&lt;P&gt;wa_cat-seltext_s = sy-index.&lt;/P&gt;&lt;P&gt;wa_cat-outputlen = '10'.&lt;/P&gt;&lt;P&gt;append wa_cat to alv_fldcat.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do p_flds times.&lt;/P&gt;&lt;P&gt;clear wa_cat.&lt;/P&gt;&lt;P&gt;wa_cat-fieldname = sy-index.&lt;/P&gt;&lt;P&gt;wa_cat-seltext_s = sy-index.&lt;/P&gt;&lt;P&gt;wa_cat-outputlen = '6'.&lt;/P&gt;&lt;P&gt;append wa_cat to alv_fldcat.&lt;/P&gt;&lt;P&gt;enddo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Call ABAP List Viewer (ALV)&lt;/P&gt;&lt;P&gt;call function 'REUSE_ALV_GRID_DISPLAY'&lt;/P&gt;&lt;P&gt;exporting&lt;/P&gt;&lt;P&gt;it_fieldcat = alv_fldcat&lt;/P&gt;&lt;P&gt;tables&lt;/P&gt;&lt;P&gt;t_outtab = &amp;lt;dyn_table&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ram.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Jul 2008 08:34:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-tables-dynamically/m-p/4134910#M988848</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-04T08:34:43Z</dc:date>
    </item>
    <item>
      <title>Re: Create tables dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-tables-dynamically/m-p/4134911#M988849</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;Is the program creating the fields dynamically? Actually I know the number of fields. It is a fixed number of fields. I need the multiple internal table to be created instead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;E.G.&lt;/P&gt;&lt;P&gt;I have following internal table definition:&lt;/P&gt;&lt;P&gt;DATA: BEGIN OF GT_TAB1 OCCURS 0,&lt;/P&gt;&lt;P&gt;LINE1 TYPE C,&lt;/P&gt;&lt;P&gt;LINE2 TYPE C,&lt;/P&gt;&lt;P&gt;END OF GT_TAB1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need multiple internal tables (GT_TAB2, GT_TAB3....) with a structure of GT_TAB1 to be created based on the selection screen.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Janet&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Jul 2008 08:47:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-tables-dynamically/m-p/4134911#M988849</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-04T08:47:23Z</dc:date>
    </item>
    <item>
      <title>Re: Create tables dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-tables-dynamically/m-p/4134912#M988850</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Lee,&lt;/P&gt;&lt;P&gt;      The following code shoul help the purpose.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This code explains about the dynamic creation of internal table according to the input database table and displaying it in an ALV Grid. Works with all sort of database tables (even huge number of records).This concept can be expanded to work with tables that have very large number of fields.	&lt;/P&gt;&lt;P&gt;By: Siva Subramanian Kalaiselvan&lt;/P&gt;&lt;P&gt;Company: Wipro Technologies&lt;/P&gt;&lt;P&gt;Date: 21 Jan. 2005&lt;/P&gt;&lt;P&gt;Code Sample&lt;/P&gt;&lt;P&gt;REPORT ZC3_DYNITABDISPALV   MESSAGE-ID zmsgdynamic.&lt;/P&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;Description           : Dynamic internal table creation and&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;                        displaying in ALV Grid.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Technical Contact     : SivaSubramanian Kalaiselvan&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Technical Spec. Number: ZC3_DYNITABDISPALV.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Created on            : 21/01/05.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Transport request     : PDCK902348.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Development Class     : zc3_sivdev.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;********************************************************************&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TABLES : tadir. " table in which the obj_name field stores all the&lt;/P&gt;&lt;P&gt;                " database table names&lt;/P&gt;&lt;P&gt;TYPE-POOLS : slis.&lt;/P&gt;&lt;P&gt;TYPES ztab LIKE dcobjdef-name .&lt;/P&gt;&lt;P&gt;	&lt;/P&gt;&lt;P&gt;DATA : dyntab LIKE dntab OCCURS 0 WITH HEADER LINE,&lt;/P&gt;&lt;P&gt;       dref TYPE REF TO data,&lt;/P&gt;&lt;P&gt;       i_fcat TYPE  lvc_t_fcat ,&lt;/P&gt;&lt;P&gt;       wa_fcat TYPE lvc_s_fcat ,&lt;/P&gt;&lt;P&gt;       w_pgm LIKE sy-repid,&lt;/P&gt;&lt;P&gt;       count TYPE i VALUE 0,&lt;/P&gt;&lt;P&gt;       w_obj_name LIKE tadir-obj_name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA : wa_fieldcat TYPE slis_fieldcat_alv,  "ALV FIELD CATALOG TABLE&lt;/P&gt;&lt;P&gt;       i_fieldcat TYPE slis_t_fieldcat_alv, "ALV FIELD CATALOG STRUCTURE&lt;/P&gt;&lt;P&gt;       i_event TYPE slis_t_event,            "ALV EVENT HANDLING TABLE&lt;/P&gt;&lt;P&gt;       wa_event TYPE slis_alv_event,         "ALV EVENT HANDLING STRUCT&lt;/P&gt;&lt;P&gt;       i_listheader TYPE slis_t_listheader,  "ALV LIST HEADER TABLE&lt;/P&gt;&lt;P&gt;       wa_listheader TYPE slis_listheader,   "ALV LIST HEADER STRUCT&lt;/P&gt;&lt;P&gt;       i_layout TYPE slis_layout_alv.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS :&amp;lt;newtab&amp;gt; TYPE table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INITIALIZATION.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  w_pgm = sy-repid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;****************SELECTION-SCREEN 2000&lt;/P&gt;&lt;P&gt;  SELECTION-SCREEN BEGIN OF SCREEN 2000 AS WINDOW.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE tit1.&lt;/P&gt;&lt;P&gt;  PARAMETERS:   tab_name TYPE ztab . " Enter database table name&lt;/P&gt;&lt;P&gt;  SELECTION-SCREEN END OF BLOCK b1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  SELECTION-SCREEN END OF SCREEN 2000.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;***************END OF SELECTION-SCREEN 2000&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  tit1 = 'Enter Table Name?'.&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;  CALL SELECTION-SCREEN 2000 STARTING AT 10 10.&lt;/P&gt;&lt;P&gt;  PERFORM occurcheck.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*********CHECKING WHETHER THE DATABASE TABLE EXISTS&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM occurcheck.&lt;/P&gt;&lt;P&gt;  SELECT obj_name FROM tadir INTO w_obj_name WHERE obj_name = tab_name.&lt;/P&gt;&lt;P&gt;  ENDSELECT.&lt;/P&gt;&lt;P&gt;  IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;    MESSAGE i003."Table not found in the database .&lt;/P&gt;&lt;P&gt;    CALL SELECTION-SCREEN 2000 STARTING AT 10 10.&lt;/P&gt;&lt;P&gt;    PERFORM occurcheck.&lt;/P&gt;&lt;P&gt;  ELSE.&lt;/P&gt;&lt;P&gt;    PERFORM startprocess.&lt;/P&gt;&lt;P&gt;    EXIT.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;**********GETTING THE FIELD NAMES OF THE INPUT DATABASE TABLE&lt;/P&gt;&lt;P&gt;FORM startprocess.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CALL FUNCTION 'NAMETAB_GET'&lt;/P&gt;&lt;P&gt;       EXPORTING&lt;/P&gt;&lt;P&gt;            langu   = sy-langu&lt;/P&gt;&lt;P&gt;            tabname = tab_name&lt;/P&gt;&lt;P&gt;       TABLES&lt;/P&gt;&lt;P&gt;            nametab = dyntab. "dntab now contains the field names&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;**********FILLING THE CATALOG OF NEW DYNAMIC INTERNAL TABLE&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  LOOP AT dyntab.&lt;/P&gt;&lt;P&gt;    wa_fcat-fieldname = dyntab-fieldname.&lt;/P&gt;&lt;P&gt;    wa_fcat-ref_field = dyntab-fieldname.&lt;/P&gt;&lt;P&gt;    wa_fcat-ref_table = dyntab-tabname.&lt;/P&gt;&lt;P&gt;    APPEND wa_fcat TO i_fcat .&lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;***********CREATING A POINTER (FIELD SYMBOL) TO THE INTERNAL TABLE&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           = i_fcat&lt;/P&gt;&lt;P&gt;    IMPORTING&lt;/P&gt;&lt;P&gt;      ep_table                  = dref.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  ASSIGN  dref-&amp;gt;* TO &amp;lt;newtab&amp;gt;.&lt;/P&gt;&lt;P&gt;  SELECT * FROM (dyntab-tabname) INTO TABLE &amp;lt;newtab&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;**********CHECKING WHETHER DATA HAS BEEN UPLOADED.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  DESCRIBE TABLE &amp;lt;newtab&amp;gt; LINES sy-tfill.&lt;/P&gt;&lt;P&gt;  DESCRIBE TABLE &amp;lt;newtab&amp;gt; LINES count.&lt;/P&gt;&lt;P&gt;  IF sy-tfill = 0 .&lt;/P&gt;&lt;P&gt;    MESSAGE i001.    "Internal table is not filled&lt;/P&gt;&lt;P&gt;  ELSE.&lt;/P&gt;&lt;P&gt;    MESSAGE i002 WITH count. "Internal table is filled&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;****************EVENTS USED IN ALV&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CALL FUNCTION 'REUSE_ALV_EVENTS_GET'&lt;/P&gt;&lt;P&gt;       EXPORTING&lt;/P&gt;&lt;P&gt;            i_list_type = 0  " 0-simple list, 1-hierarchial list.&lt;/P&gt;&lt;P&gt;       IMPORTING&lt;/P&gt;&lt;P&gt;            et_events   = i_event.&lt;/P&gt;&lt;P&gt;  SORT i_event.&lt;/P&gt;&lt;P&gt;  READ TABLE i_event&lt;/P&gt;&lt;P&gt;  WITH KEY name = slis_ev_top_of_page    "TOP_OF_PAGE event&lt;/P&gt;&lt;P&gt;  INTO wa_event.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;    MOVE 'IAM_TOP_OF_PAGE' TO wa_event-form.  "IAM_TOP_OF_PAGE will&lt;/P&gt;&lt;P&gt;    "call  subroutine automatically&lt;/P&gt;&lt;P&gt;    MODIFY i_event FROM wa_event INDEX sy-tabix.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;****************DISPLAYING ALV.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'&lt;/P&gt;&lt;P&gt;       EXPORTING&lt;/P&gt;&lt;P&gt;            i_callback_program = w_pgm&lt;/P&gt;&lt;P&gt;            i_structure_name   = dyntab-tabname&lt;/P&gt;&lt;P&gt;            it_events          = i_event&lt;/P&gt;&lt;P&gt;       TABLES&lt;/P&gt;&lt;P&gt;            t_outtab           = &amp;lt;newtab&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;**********FORM TOP_OF-PAGE.&lt;/P&gt;&lt;P&gt;******FILLING OF LIST HEADER TABLE&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM iam_top_of_page.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CLEAR wa_listheader.&lt;/P&gt;&lt;P&gt;  wa_listheader-typ = 'H'.     "HEADING&lt;/P&gt;&lt;P&gt;  wa_listheader-info = 'ALV CREATED DYNAMICALLY'.&lt;/P&gt;&lt;P&gt;  APPEND wa_listheader TO i_listheader.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CLEAR wa_listheader.&lt;/P&gt;&lt;P&gt;  wa_listheader-typ = 'S'.      "SUB-HEADING&lt;/P&gt;&lt;P&gt;  wa_listheader-key = 'PGM NAME:'.&lt;/P&gt;&lt;P&gt;  wa_listheader-info = w_pgm.&lt;/P&gt;&lt;P&gt;  APPEND wa_listheader TO i_listheader.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CLEAR wa_listheader.&lt;/P&gt;&lt;P&gt;  wa_listheader-typ = 'S'.&lt;/P&gt;&lt;P&gt;  wa_listheader-key = 'USER:'.&lt;/P&gt;&lt;P&gt;  wa_listheader-info = sy-uname.&lt;/P&gt;&lt;P&gt;  APPEND wa_listheader TO i_listheader.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CLEAR wa_listheader.&lt;/P&gt;&lt;P&gt;  wa_listheader-typ = 'S'.&lt;/P&gt;&lt;P&gt;  wa_listheader-key = 'DATE:'.&lt;/P&gt;&lt;P&gt;  wa_listheader-info = sy-datum.&lt;/P&gt;&lt;P&gt;  APPEND wa_listheader TO i_listheader.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CLEAR wa_listheader.&lt;/P&gt;&lt;P&gt;  wa_listheader-typ = 'S'.&lt;/P&gt;&lt;P&gt;  wa_listheader-key = 'TABLE NAME:'.&lt;/P&gt;&lt;P&gt;  wa_listheader-info = dyntab-tabname.&lt;/P&gt;&lt;P&gt;  APPEND wa_listheader TO i_listheader.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;********FUNCTION TO WRITE THE TITLE AND SUB-TITLE OF THE ALV.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'&lt;/P&gt;&lt;P&gt;       EXPORTING&lt;/P&gt;&lt;P&gt;            it_list_commentary = i_listheader.&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward if found usefull......!&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ram.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Jul 2008 04:57:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-tables-dynamically/m-p/4134912#M988850</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-14T04:57:29Z</dc:date>
    </item>
  </channel>
</rss>

