<?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 ABAP Query Question in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-query-question/m-p/851851#M46356</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello.  Is there a way to dynamically generate a query?  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example:  I'm doing an RFC call that sometimes the strings contains data, the other times they don't.  Is there a way of building the query to only 'and' the values when there are values there?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Like &lt;/P&gt;&lt;P&gt;a = '1'&lt;/P&gt;&lt;P&gt;b = ''&lt;/P&gt;&lt;P&gt;c = '2'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from whereever where a = 1 (dont include b because its empty) and c = 2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks,  Graeme.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 23 Dec 2004 19:41:10 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2004-12-23T19:41:10Z</dc:date>
    <item>
      <title>ABAP Query Question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-query-question/m-p/851851#M46356</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello.  Is there a way to dynamically generate a query?  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example:  I'm doing an RFC call that sometimes the strings contains data, the other times they don't.  Is there a way of building the query to only 'and' the values when there are values there?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Like &lt;/P&gt;&lt;P&gt;a = '1'&lt;/P&gt;&lt;P&gt;b = ''&lt;/P&gt;&lt;P&gt;c = '2'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from whereever where a = 1 (dont include b because its empty) and c = 2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks,  Graeme.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Dec 2004 19:41:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-query-question/m-p/851851#M46356</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2004-12-23T19:41:10Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP Query Question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-query-question/m-p/851852#M46357</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, you can.  It can be restrictive.  I've done it, though I don't have any examples to hand.  Dug up the help for it&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_47x200/helpdata/en/67/93b80914a911d2953c0000e8353423/frameset.htm" target="test_blank"&gt;http://help.sap.com/saphelp_47x200/helpdata/en/67/93b80914a911d2953c0000e8353423/frameset.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just look at dynamic conditions&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Dec 2004 20:50:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-query-question/m-p/851852#M46357</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2004-12-23T20:50:18Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP Query Question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-query-question/m-p/851853#M46358</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If anyone would have a simple example that would help alot.  That help is pretty confusing (I'm far from an ABAP guru mind you &lt;SPAN __jive_emoticon_name="wink"&gt;&lt;/SPAN&gt; )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks!  graeme&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Dec 2004 21:46:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-query-question/m-p/851853#M46358</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2004-12-23T21:46:28Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP Query Question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-query-question/m-p/851854#M46359</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Heres a good solution I found:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dynamic where clauses in open SQL&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use an internal table to build a dynamic where clause:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: where_tab(30) occurs 1 with header line,&lt;/P&gt;&lt;P&gt;where_clause(30) type c.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Build the where clause. Will look like this when finished&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;WHERE ZAFSTMD02 = 'X' AND rbusa = '5145'&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;With a constant, result: ZAFSTMD01 = 'X'&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;concatenate 'ZAFSTMD' zcostcheck-zmaaned ' = ''X''' into where_clause.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Append to internal table where_tab&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;append where_clause to where_tab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;With a variable, result: AND rbusa = '5145'&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;concatenate 'AND rbusa = ' '''' i_tab-zgsber ''''&lt;/P&gt;&lt;P&gt;append where_clause to where_tab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Select&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;select * from zcostfreq&lt;/P&gt;&lt;P&gt;where (where_tab).&lt;/P&gt;&lt;P&gt;endselect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that you can combine static and dynamic where clauses:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from zcostfreq&lt;/P&gt;&lt;P&gt;where bukrs = '2021' AND&lt;/P&gt;&lt;P&gt;(where_tab).&lt;/P&gt;&lt;P&gt;endselect.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Dec 2004 22:06:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-query-question/m-p/851854#M46359</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2004-12-23T22:06:17Z</dc:date>
    </item>
  </channel>
</rss>

