<?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 Accessing Dynamic Database Table Names (Stored in a variable) in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/accessing-dynamic-database-table-names-stored-in-a-variable/m-p/727480#M34133</link>
    <description>&lt;P&gt;Dear Experts,&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;I am currenty having a basic problem on which i hope you can help me with.&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;Suppose i have a code running and in runtime a name of a database table will be saved into the variable lv_tablename. Something like this:&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;lv_tablename = MARA.&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;I would like to work with this Variable in the following way. For example, suppose i would like to build a custom type, which contains all fields of mara with one additional custom field at the end. &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;'Something like this':&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;TYPES:
  BEGIN OF ty_custom.
    Include type mara as ty_custom.
Types:
    lastfield type c,
  END OF ty_custom.
&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; &lt;/P&gt;
  &lt;P&gt;Instead of the table name 'MARA' i want to use the content of the variable lv_tablename. Something like this:&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;TYPES:
  BEGIN OF ty_custom.
    Include type (lv_tablename) as ty_custom.
Types:
    lastfield type c,
  END OF ty_custom.
&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; &lt;/P&gt;
  &lt;P&gt;Or Use the Variable for an inner Join :&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;Select MARA~MATNR MARC~MATNR MARC~WERKS
    INTO CORRESPONDING FIELDS OF TABLE lt_table
    FROM ((lv_tablename) AS MARA
    INNER JOIN MARC AS MARC
       on MARA~MATNR = MARC~MATNR).
&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; &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;But as probably many of you already know, it doesn't work. Is there any easy way to do this? Maybe by putting the complete syntax in a variable? Any help would be appreciated!&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;</description>
    <pubDate>Mon, 09 Jul 2018 09:35:50 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2018-07-09T09:35:50Z</dc:date>
    <item>
      <title>Accessing Dynamic Database Table Names (Stored in a variable)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/accessing-dynamic-database-table-names-stored-in-a-variable/m-p/727480#M34133</link>
      <description>&lt;P&gt;Dear Experts,&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;I am currenty having a basic problem on which i hope you can help me with.&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;Suppose i have a code running and in runtime a name of a database table will be saved into the variable lv_tablename. Something like this:&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;lv_tablename = MARA.&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;I would like to work with this Variable in the following way. For example, suppose i would like to build a custom type, which contains all fields of mara with one additional custom field at the end. &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;'Something like this':&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;TYPES:
  BEGIN OF ty_custom.
    Include type mara as ty_custom.
Types:
    lastfield type c,
  END OF ty_custom.
&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; &lt;/P&gt;
  &lt;P&gt;Instead of the table name 'MARA' i want to use the content of the variable lv_tablename. Something like this:&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;TYPES:
  BEGIN OF ty_custom.
    Include type (lv_tablename) as ty_custom.
Types:
    lastfield type c,
  END OF ty_custom.
&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; &lt;/P&gt;
  &lt;P&gt;Or Use the Variable for an inner Join :&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;Select MARA~MATNR MARC~MATNR MARC~WERKS
    INTO CORRESPONDING FIELDS OF TABLE lt_table
    FROM ((lv_tablename) AS MARA
    INNER JOIN MARC AS MARC
       on MARA~MATNR = MARC~MATNR).
&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; &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;But as probably many of you already know, it doesn't work. Is there any easy way to do this? Maybe by putting the complete syntax in a variable? Any help would be appreciated!&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Mon, 09 Jul 2018 09:35:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/accessing-dynamic-database-table-names-stored-in-a-variable/m-p/727480#M34133</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2018-07-09T09:35:50Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing Dynamic Database Table Names (Stored in a variable)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/accessing-dynamic-database-table-names-stored-in-a-variable/m-p/727481#M34134</link>
      <description>&lt;P&gt;Welcome to the site!&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;Please in future, if you're posting code, using the "code" button in the editor and make sure your code is formatted nicely. Use right-click "paste as text" if pasting code copied from an editor. This time, I've done it for you.&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;Matt Billingham&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;SAP Community Moderator&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jul 2018 09:38:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/accessing-dynamic-database-table-names-stored-in-a-variable/m-p/727481#M34134</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2018-07-09T09:38:36Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing Dynamic Database Table Names (Stored in a variable)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/accessing-dynamic-database-table-names-stored-in-a-variable/m-p/727482#M34135</link>
      <description>&lt;P&gt;You can't use&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;Include type (lv_tablename) as ty_custom.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;If you want dynamic data structures, you must use the RTTS classes. (If you don't know what they are, then please search this site - there's many examples).&lt;/P&gt;
  &lt;P&gt;For the inner join - please search before posting. Often you'll find the answer without posting a question. Try: &lt;A href="https://archive.sap.com/discussions/thread/1898930" target="test_blank"&gt;https://archive.sap.com/discussions/thread/1898930&lt;/A&gt;&lt;/P&gt;
  &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jul 2018 09:43:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/accessing-dynamic-database-table-names-stored-in-a-variable/m-p/727482#M34135</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2018-07-09T09:43:18Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing Dynamic Database Table Names (Stored in a variable)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/accessing-dynamic-database-table-names-stored-in-a-variable/m-p/727483#M34136</link>
      <description>&lt;P&gt;&lt;A href="https://help.sap.com/http.svc/rc/abapdocu_752_index_htm/7.52/en-US/index.htm?file=abendynamic_sql_abexa.htm" target="test_blank"&gt;https://help.sap.com/http.svc/rc/abapdocu_752_index_htm/7.52/en-US/index.htm?file=abendynamic_sql_abexa.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jul 2018 09:53:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/accessing-dynamic-database-table-names-stored-in-a-variable/m-p/727483#M34136</guid>
      <dc:creator>retired_member</dc:creator>
      <dc:date>2018-07-09T09:53:03Z</dc:date>
    </item>
  </channel>
</rss>

