<?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: creating dynamic db tables in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/creating-dynamic-db-tables/m-p/971943#M69868</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dynamic Internal Table Example.....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

report zrich_0003
       no standard page heading.

type-pools: slis.

field-symbols: &amp;lt;dyn_table&amp;gt; type standard table,
               &amp;lt;dyn_wa&amp;gt;.

data: alv_fldcat type slis_t_fieldcat_alv,
      it_fldcat type lvc_t_fcat.


selection-screen begin of block b1 with frame title text-001.
parameters: p_check type c.
selection-screen end of block b1.

start-of-selection.

  perform build_dyn_itab.
  perform build_report.

  loop at &amp;lt;dyn_table&amp;gt; into &amp;lt;dyn_wa&amp;gt;.
    write:/ &amp;lt;dyn_wa&amp;gt;.
  endloop.


************************************************************************
*  Build_dyn_itab
************************************************************************
form build_dyn_itab.

  data: index(3) type c.

  data: new_table type ref to data,
        new_line  type ref to data,
        wa_it_fldcat type lvc_s_fcat.

* Create fields
  clear index.
  do 10 times.
    index = sy-index.
    clear wa_it_fldcat.
    concatenate 'Field' index into
             wa_it_fldcat-fieldname .
    condense  wa_it_fldcat-fieldname no-gaps.
    wa_it_fldcat-datatype = 'CHAR'.
    wa_it_fldcat-intlen = 5.
    append wa_it_fldcat to it_fldcat .
  enddo.

* Create dynamic internal table and assign to FS
  call method cl_alv_table_create=&amp;gt;create_dynamic_table
               exporting
                  it_fieldcatalog = it_fldcat
               importing
                  ep_table        = new_table.

  assign new_table-&amp;gt;* to &amp;lt;dyn_table&amp;gt;.

* Create dynamic work area and assign to FS
  create data new_line like line of &amp;lt;dyn_table&amp;gt;.
  assign new_line-&amp;gt;* to &amp;lt;dyn_wa&amp;gt;.

endform.

*********************************************************************
*      Form  build_report
*********************************************************************
form build_report.

  data: fieldname(20) type c.
  data: fieldvalue(5) type c.
  data: index(3) type c.
  field-symbols: &amp;lt;fs1&amp;gt;.

  do 10 times.

    index = sy-index.

* Set up fieldname
    concatenate 'FIELD' index into
             fieldname .
    condense   fieldname  no-gaps.

* Set up fieldvalue
    concatenate 'FLD' index into
             fieldvalue.
    condense   fieldvalue no-gaps.

    assign component  fieldname  of structure &amp;lt;dyn_wa&amp;gt; to &amp;lt;fs1&amp;gt;.
    &amp;lt;fs1&amp;gt; =  fieldvalue.

  enddo.

* Append to the dynamic internal table
  append &amp;lt;dyn_wa&amp;gt; to &amp;lt;dyn_table&amp;gt;.

endform.


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 02 Aug 2005 15:49:14 GMT</pubDate>
    <dc:creator>RichHeilman</dc:creator>
    <dc:date>2005-08-02T15:49:14Z</dc:date>
    <item>
      <title>creating dynamic db tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/creating-dynamic-db-tables/m-p/971941#M69866</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everybody,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   could any tell me  how to create a dynamic db table from se38, i need the code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  Thanks in advance&lt;/P&gt;&lt;P&gt;   srikanth.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Aug 2005 15:45:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/creating-dynamic-db-tables/m-p/971941#M69866</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-08-02T15:45:09Z</dc:date>
    </item>
    <item>
      <title>Re: creating dynamic db tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/creating-dynamic-db-tables/m-p/971942#M69867</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You want to create a Database Table during runtime?  Can you give the reason for this.  Are you sure that you don't mean a dynamic internal table?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Aug 2005 15:47:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/creating-dynamic-db-tables/m-p/971942#M69867</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2005-08-02T15:47:24Z</dc:date>
    </item>
    <item>
      <title>Re: creating dynamic db tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/creating-dynamic-db-tables/m-p/971943#M69868</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dynamic Internal Table Example.....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

report zrich_0003
       no standard page heading.

type-pools: slis.

field-symbols: &amp;lt;dyn_table&amp;gt; type standard table,
               &amp;lt;dyn_wa&amp;gt;.

data: alv_fldcat type slis_t_fieldcat_alv,
      it_fldcat type lvc_t_fcat.


selection-screen begin of block b1 with frame title text-001.
parameters: p_check type c.
selection-screen end of block b1.

start-of-selection.

  perform build_dyn_itab.
  perform build_report.

  loop at &amp;lt;dyn_table&amp;gt; into &amp;lt;dyn_wa&amp;gt;.
    write:/ &amp;lt;dyn_wa&amp;gt;.
  endloop.


************************************************************************
*  Build_dyn_itab
************************************************************************
form build_dyn_itab.

  data: index(3) type c.

  data: new_table type ref to data,
        new_line  type ref to data,
        wa_it_fldcat type lvc_s_fcat.

* Create fields
  clear index.
  do 10 times.
    index = sy-index.
    clear wa_it_fldcat.
    concatenate 'Field' index into
             wa_it_fldcat-fieldname .
    condense  wa_it_fldcat-fieldname no-gaps.
    wa_it_fldcat-datatype = 'CHAR'.
    wa_it_fldcat-intlen = 5.
    append wa_it_fldcat to it_fldcat .
  enddo.

* Create dynamic internal table and assign to FS
  call method cl_alv_table_create=&amp;gt;create_dynamic_table
               exporting
                  it_fieldcatalog = it_fldcat
               importing
                  ep_table        = new_table.

  assign new_table-&amp;gt;* to &amp;lt;dyn_table&amp;gt;.

* Create dynamic work area and assign to FS
  create data new_line like line of &amp;lt;dyn_table&amp;gt;.
  assign new_line-&amp;gt;* to &amp;lt;dyn_wa&amp;gt;.

endform.

*********************************************************************
*      Form  build_report
*********************************************************************
form build_report.

  data: fieldname(20) type c.
  data: fieldvalue(5) type c.
  data: index(3) type c.
  field-symbols: &amp;lt;fs1&amp;gt;.

  do 10 times.

    index = sy-index.

* Set up fieldname
    concatenate 'FIELD' index into
             fieldname .
    condense   fieldname  no-gaps.

* Set up fieldvalue
    concatenate 'FLD' index into
             fieldvalue.
    condense   fieldvalue no-gaps.

    assign component  fieldname  of structure &amp;lt;dyn_wa&amp;gt; to &amp;lt;fs1&amp;gt;.
    &amp;lt;fs1&amp;gt; =  fieldvalue.

  enddo.

* Append to the dynamic internal table
  append &amp;lt;dyn_wa&amp;gt; to &amp;lt;dyn_table&amp;gt;.

endform.


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Aug 2005 15:49:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/creating-dynamic-db-tables/m-p/971943#M69868</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2005-08-02T15:49:14Z</dc:date>
    </item>
    <item>
      <title>Re: creating dynamic db tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/creating-dynamic-db-tables/m-p/971944#M69869</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rich,&lt;/P&gt;&lt;P&gt;         Yesterday i had an interview in abap and the interviewer asked me how to create a database table in se38 during runtime.so that is the question?.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  cheers&lt;/P&gt;&lt;P&gt;  srikanth.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Aug 2005 16:11:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/creating-dynamic-db-tables/m-p/971944#M69869</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-08-02T16:11:22Z</dc:date>
    </item>
    <item>
      <title>Re: creating dynamic db tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/creating-dynamic-db-tables/m-p/971945#M69870</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Wow, I would say that the interviewer doesn't know what he is talking about.  I don't see any reason why you would have to create a database table at runtime.  Now there are many uses for creating a dynamic internal table at runtime, which I have shown above.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anyone else know of a specific reason why someone would want to create a database table at runtime?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Aug 2005 16:18:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/creating-dynamic-db-tables/m-p/971945#M69870</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2005-08-02T16:18:29Z</dc:date>
    </item>
    <item>
      <title>Re: creating dynamic db tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/creating-dynamic-db-tables/m-p/971946#M69871</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The only way you can do that is by using open sql statements of the underlying database. Alternatively, you may be able to use some function modules like DB_CREATE_TABLE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Srinivas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Aug 2005 16:18:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/creating-dynamic-db-tables/m-p/971946#M69871</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-08-02T16:18:58Z</dc:date>
    </item>
    <item>
      <title>Re: creating dynamic db tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/creating-dynamic-db-tables/m-p/971947#M69872</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I suppose that this FM can create a database table. I have never used ii.&lt;/P&gt;&lt;P&gt;FM 'DD_CREATE_TABLE'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Svetlin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Aug 2005 16:19:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/creating-dynamic-db-tables/m-p/971947#M69872</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-08-02T16:19:49Z</dc:date>
    </item>
    <item>
      <title>Re: creating dynamic db tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/creating-dynamic-db-tables/m-p/971948#M69873</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are some instances where SAP creates the DD tables on the fly. This is particularly true with condition tables, infostructures etc. as the fields of these tables are defined in configuration by a consultant.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unless this company which interviewed him is involved in some product like that, I don't see why a normal ABAPer would require to create a DB table on the fly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Srinivas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Aug 2005 16:23:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/creating-dynamic-db-tables/m-p/971948#M69873</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-08-02T16:23:28Z</dc:date>
    </item>
    <item>
      <title>Re: creating dynamic db tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/creating-dynamic-db-tables/m-p/971949#M69874</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks in advance, is there the possibility to read from&lt;/P&gt;&lt;P&gt;an external database like SQL/server or ORACLE ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Oct 2005 16:32:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/creating-dynamic-db-tables/m-p/971949#M69874</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-10-27T16:32:48Z</dc:date>
    </item>
    <item>
      <title>Re: creating dynamic db tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/creating-dynamic-db-tables/m-p/971950#M69875</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, using Native SQL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Oct 2005 17:11:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/creating-dynamic-db-tables/m-p/971950#M69875</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2005-10-27T17:11:00Z</dc:date>
    </item>
    <item>
      <title>Re: creating dynamic db tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/creating-dynamic-db-tables/m-p/971951#M69876</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could create TEMPORARY TABLES using Native SQL statements.  But, there is really no point to "clog up" DB server space or processing time when the ABAP language supports such a wonderful data object like... the internal table (which resides outside of the DB server).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would guess that was the answer that the interviewer was looking to get.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Oct 2005 17:21:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/creating-dynamic-db-tables/m-p/971951#M69876</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-10-27T17:21:34Z</dc:date>
    </item>
    <item>
      <title>Re: creating dynamic db tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/creating-dynamic-db-tables/m-p/971952#M69877</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I believe that I've seen (but cannot find an example) of cases where tables are dropped and then re-created. I think this is done to avoid long run times and the possibilities of SQL errors if all data in a large user table has to be deleted before being re-populated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This was done using native SQL, but I guess FMs could also be used.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Oct 2005 21:06:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/creating-dynamic-db-tables/m-p/971952#M69877</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-10-27T21:06:45Z</dc:date>
    </item>
    <item>
      <title>Re: creating dynamic db tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/creating-dynamic-db-tables/m-p/971953#M69878</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks for the answer.&lt;/P&gt;&lt;P&gt;Riccardo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Nov 2005 11:37:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/creating-dynamic-db-tables/m-p/971953#M69878</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-11-16T11:37:35Z</dc:date>
    </item>
    <item>
      <title>Re: creating dynamic db tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/creating-dynamic-db-tables/m-p/971954#M69879</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks for the answer.&lt;/P&gt;&lt;P&gt;Riccardo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Nov 2005 11:37:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/creating-dynamic-db-tables/m-p/971954#M69879</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-11-16T11:37:52Z</dc:date>
    </item>
  </channel>
</rss>

