<?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 Absolute dynamic select query with dynamic join and where in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/absolute-dynamic-select-query-with-dynamic-join-and-where/m-p/7628567#M1570984</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Has anyone ever tried creating an absolutely dynamic SELECT query with dynamic Join and Where conditions.&lt;/P&gt;&lt;P&gt;I have a requirement of creating such a query in an Utility Class, and i have written the code. But its throwing my sysntax errors.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please let me know where am I going wrong OR is it really possible to create such a dynamic Query??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

    SELECT (FIELDS) INTO TABLE IT_TABLES 
      FROM ( (ME-&amp;gt;TABLE1)  inner join ( me-&amp;gt;table2 )
      on ( on_condition ) )
      WHERE (me-&amp;gt;where_fields).

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ags.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 23 Feb 2011 07:45:18 GMT</pubDate>
    <dc:creator>agnihotro_sinha2</dc:creator>
    <dc:date>2011-02-23T07:45:18Z</dc:date>
    <item>
      <title>Absolute dynamic select query with dynamic join and where</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/absolute-dynamic-select-query-with-dynamic-join-and-where/m-p/7628567#M1570984</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Has anyone ever tried creating an absolutely dynamic SELECT query with dynamic Join and Where conditions.&lt;/P&gt;&lt;P&gt;I have a requirement of creating such a query in an Utility Class, and i have written the code. But its throwing my sysntax errors.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please let me know where am I going wrong OR is it really possible to create such a dynamic Query??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

    SELECT (FIELDS) INTO TABLE IT_TABLES 
      FROM ( (ME-&amp;gt;TABLE1)  inner join ( me-&amp;gt;table2 )
      on ( on_condition ) )
      WHERE (me-&amp;gt;where_fields).

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ags.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Feb 2011 07:45:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/absolute-dynamic-select-query-with-dynamic-join-and-where/m-p/7628567#M1570984</guid>
      <dc:creator>agnihotro_sinha2</dc:creator>
      <dc:date>2011-02-23T07:45:18Z</dc:date>
    </item>
    <item>
      <title>Re: Absolute dynamic select query with dynamic join and where</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/absolute-dynamic-select-query-with-dynamic-join-and-where/m-p/7628568#M1570985</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It worked for me in a following way:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;select * into corresponding fields of table &amp;lt;result_table&amp;gt;
        from (join_string)
        where (l_where).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Where the contents of join_string were dynamically build using concatenation. So it will be something like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;concatenate ME-&amp;gt;TABLE1 'as a INNER JOIN' me-&amp;gt;table2 'as b ON (' into join_string separated by space.
&amp;lt;...&amp;gt; 
add here matching/reference colums, something like

concatenate 'a~' me-&amp;gt;TABLE1_JOIN_COL into temp1.
concatenate 'b~' me-&amp;gt;TABLE2_JOIN_COL into temp2.
concatenate join_string temp1 '=' temp2 into join_string separated by space.
 &amp;lt;...&amp;gt;

concatenate join_string ')' into join_string separated by space.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And then use similar approach for l_where variable.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Feb 2011 08:56:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/absolute-dynamic-select-query-with-dynamic-join-and-where/m-p/7628568#M1570985</guid>
      <dc:creator>audrius_peseckis</dc:creator>
      <dc:date>2011-02-23T08:56:14Z</dc:date>
    </item>
  </channel>
</rss>

