<?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: Dynamic From statement in select query and/or outer join not working in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-from-statement-in-select-query-and-or-outer-join-not-working/m-p/6808063#M1468559</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey thanks for the reply, but the problem is not solved.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am already using  ( fileds, value) like table in my where condition and the select statement was working properly.&lt;/P&gt;&lt;P&gt;the problem is that now I have to include some tables in the join statement which can be empty and so i want to use Outer join.&lt;/P&gt;&lt;P&gt;But I am getting a runtime error as below:&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------------------------------------------------------------------------------------" /&gt;&lt;P&gt;Error analysis&lt;/P&gt;&lt;P&gt;    An exception occurred that is explained in detail below.&lt;/P&gt;&lt;P&gt;    The exception, which is assigned to class 'CX_SY_DYNAMIC_OSQL_SYNTAX', was not&lt;/P&gt;&lt;P&gt;     caught in&lt;/P&gt;&lt;P&gt;    procedure "ZATSCSNG_RFC_READ_TABLE" "(FUNCTION)", nor was it propagated by a&lt;/P&gt;&lt;P&gt;     RAISING clause.&lt;/P&gt;&lt;P&gt;    Since the caller of the procedure could not have anticipated that the&lt;/P&gt;&lt;P&gt;    exception would occur, the current program is terminated.&lt;/P&gt;&lt;P&gt;    The reason for the exception is:&lt;/P&gt;&lt;P&gt;    The running ABAP program wanted to execute a SELECT statement whose&lt;/P&gt;&lt;P&gt;    WHERE condition was (partly) specified dynamically. The part that is&lt;/P&gt;&lt;P&gt;    specified in an internal table at runtime is compared to a field of the&lt;/P&gt;&lt;P&gt;    right table of an LEFT OUTER JOIN. Such comparisons are not supported by&lt;/P&gt;&lt;P&gt;     all database systems and are therefore not allowed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="---------------------------------------------------------------------------------------------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 24 Mar 2010 14:42:49 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-03-24T14:42:49Z</dc:date>
    <item>
      <title>Dynamic From statement in select query and/or outer join not working</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-from-statement-in-select-query-and-or-outer-join-not-working/m-p/6808061#M1468557</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Experts, I have a select query where the select columns are dynamic, the where condition is also dynamic. It is of the below format:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select (dynamic columns) INTO &amp;lt;wa&amp;gt;&lt;/P&gt;&lt;P&gt;FROM a inner join b on a&lt;SUB&gt;f1 = b&lt;/SUB&gt;f1&lt;/P&gt;&lt;P&gt;inner join c on a&lt;SUB&gt;f2 = c&lt;/SUB&gt;f2......&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WHERE (dynamic conditios)&lt;/P&gt;&lt;P&gt;ORDER BY ( dynamic sort condition).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I have to include some tables (dynamically depending on the user input) in the inner join statement which will give description for the selected fields. And these database tables may or may no be empty. So in this case, my select query will not return any data if these tables are empty. And I dont want that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried using outer join for the extra tables but it gave me a runtime error. I also tried forming the inner join statement dynamically but it was not supporting. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kindly give me pointers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Mar 2010 14:02:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-from-statement-in-select-query-and-or-outer-join-not-working/m-p/6808061#M1468557</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-03-24T14:02:02Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic From statement in select query and/or outer join not working</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-from-statement-in-select-query-and-or-outer-join-not-working/m-p/6808062#M1468558</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;For where condition use this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: BEGIN OF it_selopt OCCURS 0,
        field      TYPE string,
        value      TYPE string,
      END OF it_selopt,
      wa_selopt LIKE LINE OF it_selopt.
 
DATA cond_syntax TYPE string.
 
                ............
 
it_selopt-field = 'MATNR'.
it_selopt-value = ''Hello''.
APPEND it_selopt.
 
 
LOOP AT it_selopt.
  wa_selopt = it_selopt.
 
* First condition
  AT FIRST.
       CONCATENATE wa_selopt-field '=' wa_selopt-value
         INTO cond_syntax SEPARATED BY space.
    CONTINUE.  "
  ENDAT.
* Other conditions  
       CONCATENATE cond_syntax 'AND' wa_selopt-field '=' wa_selopt-value
            INTO cond_syntax SEPARATED BY space.
ENDLOOP.
 
 
TRY. 
    SELECT SINGLE * 
           FROM eban 
           WHERE (cond_syntax). 
 
  CATCH cx_sy_dynamic_osql_error. 
    MESSAGE `Wrong WHERE condition!` TYPE 'I'. 
ENDTRY.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marco&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Mar 2010 14:32:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-from-statement-in-select-query-and-or-outer-join-not-working/m-p/6808062#M1468558</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-03-24T14:32:39Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic From statement in select query and/or outer join not working</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-from-statement-in-select-query-and-or-outer-join-not-working/m-p/6808063#M1468559</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey thanks for the reply, but the problem is not solved.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am already using  ( fileds, value) like table in my where condition and the select statement was working properly.&lt;/P&gt;&lt;P&gt;the problem is that now I have to include some tables in the join statement which can be empty and so i want to use Outer join.&lt;/P&gt;&lt;P&gt;But I am getting a runtime error as below:&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------------------------------------------------------------------------------------" /&gt;&lt;P&gt;Error analysis&lt;/P&gt;&lt;P&gt;    An exception occurred that is explained in detail below.&lt;/P&gt;&lt;P&gt;    The exception, which is assigned to class 'CX_SY_DYNAMIC_OSQL_SYNTAX', was not&lt;/P&gt;&lt;P&gt;     caught in&lt;/P&gt;&lt;P&gt;    procedure "ZATSCSNG_RFC_READ_TABLE" "(FUNCTION)", nor was it propagated by a&lt;/P&gt;&lt;P&gt;     RAISING clause.&lt;/P&gt;&lt;P&gt;    Since the caller of the procedure could not have anticipated that the&lt;/P&gt;&lt;P&gt;    exception would occur, the current program is terminated.&lt;/P&gt;&lt;P&gt;    The reason for the exception is:&lt;/P&gt;&lt;P&gt;    The running ABAP program wanted to execute a SELECT statement whose&lt;/P&gt;&lt;P&gt;    WHERE condition was (partly) specified dynamically. The part that is&lt;/P&gt;&lt;P&gt;    specified in an internal table at runtime is compared to a field of the&lt;/P&gt;&lt;P&gt;    right table of an LEFT OUTER JOIN. Such comparisons are not supported by&lt;/P&gt;&lt;P&gt;     all database systems and are therefore not allowed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="---------------------------------------------------------------------------------------------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Mar 2010 14:42:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-from-statement-in-select-query-and-or-outer-join-not-working/m-p/6808063#M1468559</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-03-24T14:42:49Z</dc:date>
    </item>
  </channel>
</rss>

