<?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: Table name decided at runtime - How to do a select? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-name-decided-at-runtime-how-to-do-a-select/m-p/5142021#M1191834</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try concatenating the value of dbtab_syntax from your variables and the literals inbetween.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;e.g.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CONCATENATE dynamic_tabname1 ' AS tab1 JOIN ' dynamic_tabname2 ' AS tab2 ON ... ' INTO dbtab_syntax.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 05 Feb 2009 14:18:20 GMT</pubDate>
    <dc:creator>ThomasZloch</dc:creator>
    <dc:date>2009-02-05T14:18:20Z</dc:date>
    <item>
      <title>Table name decided at runtime - How to do a select?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-name-decided-at-runtime-how-to-do-a-select/m-p/5142011#M1191824</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;Searching these forums I found how to do a select * from where the table name is decided at runtime. You use paranthesis on the variable containing the table name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I still get syntax error I can't solve and need some help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;This syntax doesnt work&lt;/STRONG&gt;, could you help me find out what is the problem?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT tab1~field1 tab2~field2
FROM ( (dynamic_tab_name1) AS tab1 INNER JOIN
       (dynamic_tab_name2) AS tab2 ON tab1~someIndex = tab2~someIndex )&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;dynamic_tab_name1 and dynamic_tab_name2 are defined as two strings where I concatenate the table prefix name with the system client number.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The syntax works if&lt;/STRONG&gt; i replace the dynamic_tab_name1 and dynamic_tab_name2 with hardcoded table names.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks &amp;amp; regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Baran Sölen on Feb 5, 2009 1:44 PM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Feb 2009 12:43:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-name-decided-at-runtime-how-to-do-a-select/m-p/5142011#M1191824</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-05T12:43:30Z</dc:date>
    </item>
    <item>
      <title>Re: Table name decided at runtime - How to do a select?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-name-decided-at-runtime-how-to-do-a-select/m-p/5142012#M1191825</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;Please find the Code below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA wa TYPE scarr.&lt;/P&gt;&lt;P&gt;DATA name(10) TYPE c VALUE 'SCARR'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT *&lt;/P&gt;&lt;P&gt;INTO wa&lt;/P&gt;&lt;P&gt;FROM (name) CLIENT SPECIFIED&lt;/P&gt;&lt;P&gt;WHERE mandt = '000'.&lt;/P&gt;&lt;P&gt;WRITE: / wa-carrid, wa-carrname.&lt;/P&gt;&lt;P&gt;ENDSELECT. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[Link|http://help.sap.com/saphelp_47x200/helpdata/en/c6/617cf4e68c11d2b2ab080009b43351/content.htm]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this is help Full&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;kalyan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Feb 2009 12:46:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-name-decided-at-runtime-how-to-do-a-select/m-p/5142012#M1191825</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-05T12:46:39Z</dc:date>
    </item>
    <item>
      <title>Re: Table name decided at runtime - How to do a select?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-name-decided-at-runtime-how-to-do-a-select/m-p/5142013#M1191826</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Baran&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
FIELD-SYMBOLS : &amp;lt;FS1&amp;gt; TYPE TABLE, &amp;lt;FS2&amp;gt; TYPE TABLE.

ASSIGN (dynamic_tab_name1) TO &amp;lt;FS1&amp;gt;.
ASSIGN (dynamic_tab_name2) TO &amp;lt;FS2&amp;gt;.

SELECT tab1~field1 tab2~field2
FROM ( &amp;lt;FS1&amp;gt; AS tab1 INNER JOIN
       &amp;lt;FS1&amp;gt; AS tab2 ON tab1~someIndex = tab2~someIndex )

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pushpraj&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Feb 2009 12:51:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-name-decided-at-runtime-how-to-do-a-select/m-p/5142013#M1191826</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-05T12:51:01Z</dc:date>
    </item>
    <item>
      <title>Re: Table name decided at runtime - How to do a select?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-name-decided-at-runtime-how-to-do-a-select/m-p/5142014#M1191827</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You would have to put the entire JOIN syntax into a variable, see the example here:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/abapdocu/en/ABAPFROM_CLAUSE.htm#!ABAP_ALTERNATIVE_3@3@" target="test_blank"&gt;http://help.sap.com/abapdocu/en/ABAPFROM_CLAUSE.htm#!ABAP_ALTERNATIVE_3@3@&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Feb 2009 12:55:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-name-decided-at-runtime-how-to-do-a-select/m-p/5142014#M1191827</guid>
      <dc:creator>ThomasZloch</dc:creator>
      <dc:date>2009-02-05T12:55:01Z</dc:date>
    </item>
    <item>
      <title>Re: Table name decided at runtime - How to do a select?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-name-decided-at-runtime-how-to-do-a-select/m-p/5142015#M1191828</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;   Also you can move the value of the dynamic table into a character data object and then use them in the Join condition.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Viquar Iqbal&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Feb 2009 12:55:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-name-decided-at-runtime-how-to-do-a-select/m-p/5142015#M1191828</guid>
      <dc:creator>viquar_iqbal</dc:creator>
      <dc:date>2009-02-05T12:55:19Z</dc:date>
    </item>
    <item>
      <title>Re: Table name decided at runtime - How to do a select?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-name-decided-at-runtime-how-to-do-a-select/m-p/5142016#M1191829</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;STRONG&gt;Pushpraj Singh&lt;/STRONG&gt; : That didnt work either. If you try that you will get the syntax error (try yourself): &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;FS1&amp;gt; is not defined in the ABAP dictionary as a table, projection, view or database view.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Feb 2009 13:21:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-name-decided-at-runtime-how-to-do-a-select/m-p/5142016#M1191829</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-05T13:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: Table name decided at runtime - How to do a select?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-name-decided-at-runtime-how-to-do-a-select/m-p/5142017#M1191830</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Instead when you have dynamic tables you can go for for all entires and &lt;/P&gt;&lt;P&gt;can implement the logic of inner join.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example check the below sample code,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here to aboid inner join of mara and marc i ve used for all entries&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: it_tab TYPE TABLE OF ty_tab,
      it_matnr TYPE TABLE OF ty_matnr,
      wa_tab TYPE ty_tab,
      wa_matnr TYPE ty_matnr.

DATA: w_tab1 TYPE tabname,
      w_tab2 TYPE tabname.

w_tab1 = 'MARA'.
w_tab2 = 'MARC'.

DATA: BEGIN OF it_fields OCCURS 0,
      field TYPE fieldname,
      END OF it_fields.

it_fields-field = 'MATNR'.
APPEND it_fields.




SELECT (it_fields) UP TO 10 ROWS
       INTO TABLE it_matnr
       FROM (w_tab1).

REFRESH it_fields[].

it_fields-field = 'MATNR'.
APPEND it_fields.

it_fields-field = 'WERKS'.
APPEND it_fields.

SELECT (it_fields) UP TO 10 ROWS
       INTO TABLE it_tab
        FROM (w_tab2)
       FOR ALL ENTRIES IN it_matnr
       WHERE matnr = it_matnr-matnr.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps you.&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;Manoj Kumar P&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Feb 2009 13:27:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-name-decided-at-runtime-how-to-do-a-select/m-p/5142017#M1191830</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-05T13:27:23Z</dc:date>
    </item>
    <item>
      <title>Re: Table name decided at runtime - How to do a select?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-name-decided-at-runtime-how-to-do-a-select/m-p/5142018#M1191831</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Baran&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try FIELD-SYMBOLS : &amp;lt;FS1&amp;gt; TYPE ANY.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pushpraj&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Feb 2009 13:45:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-name-decided-at-runtime-how-to-do-a-select/m-p/5142018#M1191831</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-05T13:45:54Z</dc:date>
    </item>
    <item>
      <title>Re: Table name decided at runtime - How to do a select?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-name-decided-at-runtime-how-to-do-a-select/m-p/5142019#M1191832</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Doesn't work with field-symbols, declaration does not matter.&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Feb 2009 13:48:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-name-decided-at-runtime-how-to-do-a-select/m-p/5142019#M1191832</guid>
      <dc:creator>ThomasZloch</dc:creator>
      <dc:date>2009-02-05T13:48:26Z</dc:date>
    </item>
    <item>
      <title>Re: Table name decided at runtime - How to do a select?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-name-decided-at-runtime-how-to-do-a-select/m-p/5142020#M1191833</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;STRONG&gt;Thomas:&lt;/STRONG&gt; I have read the example you've sent me. Unfortunately there is problem with that example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I put everything in a string like the example but then noticed one thing (and this is probably an easy thing for experienced programmers to solve):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The table names they use in the string are not decided at runtime but that table scarr they use as an example is a table defined in the program. I get a runtime error ( cx_sy_dynamic_osql_semantics) when trying to do this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;from_syntax = `( (dynamic_tabname1) AS tab1`
                &amp;amp; ` INNER JOIN (dynamic_tabname2) AS tab2`
                &amp;amp; ` ON tab1~someIndex = oph~someIndex ).`.


SELECT tab1~field1 tab2~field2
FROM (from_syntax)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is for me hovever not strange. And again, in the example they have "scarr" as an existing table where in my case i dont know the tablename in advance but set the string dynamic_tabname1 during runtime. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Again, &lt;STRONG&gt;can anyone write any code with INNER JOINS where the table names are set during runtime&lt;/STRONG&gt;?!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Baran Sölen on Feb 5, 2009 3:02 PM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Baran Sölen on Feb 5, 2009 3:05 PM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Feb 2009 14:01:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-name-decided-at-runtime-how-to-do-a-select/m-p/5142020#M1191833</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-05T14:01:31Z</dc:date>
    </item>
    <item>
      <title>Re: Table name decided at runtime - How to do a select?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-name-decided-at-runtime-how-to-do-a-select/m-p/5142021#M1191834</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try concatenating the value of dbtab_syntax from your variables and the literals inbetween.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;e.g.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CONCATENATE dynamic_tabname1 ' AS tab1 JOIN ' dynamic_tabname2 ' AS tab2 ON ... ' INTO dbtab_syntax.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Feb 2009 14:18:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-name-decided-at-runtime-how-to-do-a-select/m-p/5142021#M1191834</guid>
      <dc:creator>ThomasZloch</dc:creator>
      <dc:date>2009-02-05T14:18:20Z</dc:date>
    </item>
    <item>
      <title>Re: Table name decided at runtime - How to do a select?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-name-decided-at-runtime-how-to-do-a-select/m-p/5142022#M1191835</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Baran,&lt;/P&gt;&lt;P&gt;1. Create a parameter,&lt;/P&gt;&lt;P&gt;PARAMETERS:&lt;/P&gt;&lt;P&gt;  p_tbname type dd02l-tabname. &lt;/P&gt;&lt;P&gt;This will provide F4-help to choose database table, since DD02L contains all database table names.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Create a table exactly like the structure of chosen table,&lt;/P&gt;&lt;P&gt;    DATA T_TABLE LIKE STANDARD TABLE OF P_TBNAME WITH HEADER LINE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. Run a select query,&lt;/P&gt;&lt;P&gt;    select * &lt;/P&gt;&lt;P&gt;    from (p_tbname)&lt;/P&gt;&lt;P&gt;    into table t_table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try doing different test-cases.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thankyou,&lt;/P&gt;&lt;P&gt;Zahack.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Feb 2009 14:26:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-name-decided-at-runtime-how-to-do-a-select/m-p/5142022#M1191835</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-05T14:26:05Z</dc:date>
    </item>
    <item>
      <title>Re: Table name decided at runtime - How to do a select?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-name-decided-at-runtime-how-to-do-a-select/m-p/5142023#M1191836</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Have you tried converting your for join logic to for all entries logic as I've mentioned above?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Feb 2009 14:28:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-name-decided-at-runtime-how-to-do-a-select/m-p/5142023#M1191836</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-05T14:28:08Z</dc:date>
    </item>
    <item>
      <title>Re: Table name decided at runtime - How to do a select?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-name-decided-at-runtime-how-to-do-a-select/m-p/5142024#M1191837</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well you can generate your program dynamically in the following way. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I never like to use the method. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

append 'PROGRAM SUBPOOL no standard page heading.' to code.
append 'form dyn1.' to code.
append 'data: begin of i_tab occurs 0,' to code.
append '      kolnr like t682i-kolnr,' to code.
append '      gstxt like tmc1t-gstxt,' to code.
append '      kschl like t685-kschl,' to code.
append '      vkorg like komg-vkorg,' to code.
append '      vtweg like komg-vtweg,' to code.
append '      matkl like komg-matkl,' to code.
append '      matnr like komg-matnr,' to code.
append '      inco1 like komg-inco1,' to code.
append '      inco2 like komg-inco2,' to code.
append '      charg like komg-charg,' to code.
append '      vkbur like komg-vkbur,' to code.
append '      vkgrp like komg-vkgrp,' to code.
append '      zsales like komg-zsales,' to code.
append '      end of i_tab.' to code.

append 'data: begin of i_t682 occurs 0,' to code.
append '      kolnr like t682i-kolnr,' to code.
append '      kotabnr like t682i-kotabnr,' to code.
append '      end of i_t682.' to code.

data: v_table_name(16),
      v_condition_type_code(72),
      v_kolnr like t682i-kolnr.

concatenate 'kschl = ''' p_kschl  '''.' into v_condition_type_code.
  loop at i_t682.

    concatenate 'A' i_t682-kotabnr into v_table_name.
    append 'select * from' to code.
    append v_table_name to code.
    append 'appending corresponding fields of table i_tab' to code.
    append 'where kappl = ''V'' and' to code.
    append v_condition_type_code to code.
    append 'if sy-subrc = 0.' to code.
    append 'loop at i_tab where kolnr = '' ''.' to code.
    concatenate 'i_tab-kolnr = ' i_t682-kolnr '.' into code separated by space.
    append code. clear code.
    append 'i_tab-gstxt = ''Description will be put later''.' to code.
    append 'modify i_tab.' to code.
    append 'endloop.' to code.
    append 'endif.' to code.

  endloop.
append 'export i_tab to memory id ''i_tab''.' to code.
append 'endform.' to code.
generate subroutine pool code
         name prog
         message msg
         line lin
         word wrd
         offset off.
*break-point.
if sy-subrc = 0.
  perform dyn1 in program (prog).
endif.
import i_tab from memory id 'i_tab'.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Feb 2009 14:35:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-name-decided-at-runtime-how-to-do-a-select/m-p/5142024#M1191837</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-05T14:35:16Z</dc:date>
    </item>
    <item>
      <title>Re: Table name decided at runtime - How to do a select?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-name-decided-at-runtime-how-to-do-a-select/m-p/5142025#M1191838</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Many thanks to helpful answers. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried Thomas tip first and it worked, thank you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks Manoj for the useful tip, that is an option as well.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Feb 2009 15:09:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-name-decided-at-runtime-how-to-do-a-select/m-p/5142025#M1191838</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-05T15:09:17Z</dc:date>
    </item>
  </channel>
</rss>

