<?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: Effective Single Query... in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/effective-single-query/m-p/3771279#M907438</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It looks like everyone is too busy to write the queries for you (hey, people get paid for this! &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt; ), but let me clue you in.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first 2 guys can be combined with a JOIN. The other 3 could be added via so called subquery. Look up ABAP Help on SELECT command and there should be an entry for subqueries. Here is an example from ABAP Help just to illustrate the idea:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT SINGLE city latitude longitude 
         INTO (city, lati, longi) 
         FROM sgeocity 
         WHERE city IN ( SELECT cityfrom 
                                FROM spfli 
                                WHERE carrid = carr_id AND 
                                      connid = conn_id ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If everything does not have to be in one very big and complex SELECT, you might also want to use an internal table and FOR ALL ENTRIES. Make sure to check if the table is not empty before doing FOR ALL ENTRIES.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Once again, you'll find all the information in ABAP Help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 08 May 2008 21:06:14 GMT</pubDate>
    <dc:creator>Jelena_Perfiljeva</dc:creator>
    <dc:date>2008-05-08T21:06:14Z</dc:date>
    <item>
      <title>Effective Single Query...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/effective-single-query/m-p/3771278#M907437</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a need to combine multiple queries into single and declare it as cursor. This would minimize the complexities in defing cursor for a BI Extractor. These queries are on the same table but with deifferent selection condition. COuld anyone combine and give a single query and how it can be done?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. SELECT PERNR USRID FROM PA0105 WHERE SUBTY = '0001'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. SELECT PLANS FROM PA0001 WHERE PERNR = PERNR from Step 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. SELECT SOBID FROM HRP1001 WHERE OTYPE = 'S'   AND &lt;/P&gt;&lt;P&gt;                                   PLVAR = '01'  AND&lt;/P&gt;&lt;P&gt;                                   RSIGN = 'A'   AND&lt;/P&gt;&lt;P&gt;                                   RELAT = '003' AND&lt;/P&gt;&lt;P&gt;                                   SCLAS = 'O'   AND&lt;/P&gt;&lt;P&gt;                                   OBJID = PLANS from step 2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4. SELECT SOBID FROM HRP1001 WHERE OTYPE = 'S'   AND &lt;/P&gt;&lt;P&gt;                                   PLVAR = '01'  AND&lt;/P&gt;&lt;P&gt;                                   RSIGN = 'A'   AND&lt;/P&gt;&lt;P&gt;                                   RELAT = '003' AND&lt;/P&gt;&lt;P&gt;                                   SCLAS = 'O'   AND&lt;/P&gt;&lt;P&gt;                                   ONJID = SOBID from step 3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;5. SELECT SOBID FROM HRP1001 WHERE OTYPE = 'O'   AND&lt;/P&gt;&lt;P&gt;                                   PLVAR = '01'  AND&lt;/P&gt;&lt;P&gt;                                   RSIGN = 'B'   AND&lt;/P&gt;&lt;P&gt;                                   RELAT = '012' AND&lt;/P&gt;&lt;P&gt;                                   SCLAS = 'S'   AND&lt;/P&gt;&lt;P&gt;                                   OBJID = SOBID from Step 4.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;Alex.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 May 2008 20:08:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/effective-single-query/m-p/3771278#M907437</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-06T20:08:39Z</dc:date>
    </item>
    <item>
      <title>Re: Effective Single Query...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/effective-single-query/m-p/3771279#M907438</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It looks like everyone is too busy to write the queries for you (hey, people get paid for this! &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt; ), but let me clue you in.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first 2 guys can be combined with a JOIN. The other 3 could be added via so called subquery. Look up ABAP Help on SELECT command and there should be an entry for subqueries. Here is an example from ABAP Help just to illustrate the idea:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT SINGLE city latitude longitude 
         INTO (city, lati, longi) 
         FROM sgeocity 
         WHERE city IN ( SELECT cityfrom 
                                FROM spfli 
                                WHERE carrid = carr_id AND 
                                      connid = conn_id ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If everything does not have to be in one very big and complex SELECT, you might also want to use an internal table and FOR ALL ENTRIES. Make sure to check if the table is not empty before doing FOR ALL ENTRIES.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Once again, you'll find all the information in ABAP Help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 May 2008 21:06:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/effective-single-query/m-p/3771279#M907438</guid>
      <dc:creator>Jelena_Perfiljeva</dc:creator>
      <dc:date>2008-05-08T21:06:14Z</dc:date>
    </item>
    <item>
      <title>Re: Effective Single Query...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/effective-single-query/m-p/3771280#M907439</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Due to performance issues, Sub query usage is not recommanded when it can be done with join. But anyway I solved this issue and closing this question. Thanks for your replies.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 May 2008 16:30:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/effective-single-query/m-p/3771280#M907439</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-15T16:30:40Z</dc:date>
    </item>
  </channel>
</rss>

