<?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 Appropriate select querry needed in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/appropriate-select-querry-needed/m-p/6497937#M1421259</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need appropriate select query for the below :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT  PLNNR
             PLNKN
             ARBID
             WERKS
             BMSCH
             VGE02
             VGW02 FROM PLPO
       INTO TABLE IT_PLPO
      FOR ALL ENTRIES IN IT_CRHD
      WHERE WERKS EQ IT_CRHD-WERKS    AND ARBID EQ IT_CRHD-OBJID     
         AND PLNTY EQ 'N'.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Please advice a appropriate select querry for the above as,&lt;/P&gt;&lt;P&gt;If use the above querry it will fetch all 50-70 records for a single wa_crhd-objid&lt;/P&gt;&lt;P&gt;but I need only a single line where plpo~vgw02 is maximum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ie:  my where conditon should satisfy &lt;STRONG&gt;max ( vgw02 ) from PLPO&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regds,&lt;/P&gt;&lt;P&gt;R.Karthik&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 08 Jan 2010 06:47:52 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-01-08T06:47:52Z</dc:date>
    <item>
      <title>Appropriate select querry needed</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/appropriate-select-querry-needed/m-p/6497937#M1421259</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need appropriate select query for the below :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT  PLNNR
             PLNKN
             ARBID
             WERKS
             BMSCH
             VGE02
             VGW02 FROM PLPO
       INTO TABLE IT_PLPO
      FOR ALL ENTRIES IN IT_CRHD
      WHERE WERKS EQ IT_CRHD-WERKS    AND ARBID EQ IT_CRHD-OBJID     
         AND PLNTY EQ 'N'.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Please advice a appropriate select querry for the above as,&lt;/P&gt;&lt;P&gt;If use the above querry it will fetch all 50-70 records for a single wa_crhd-objid&lt;/P&gt;&lt;P&gt;but I need only a single line where plpo~vgw02 is maximum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ie:  my where conditon should satisfy &lt;STRONG&gt;max ( vgw02 ) from PLPO&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regds,&lt;/P&gt;&lt;P&gt;R.Karthik&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Jan 2010 06:47:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/appropriate-select-querry-needed/m-p/6497937#M1421259</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-01-08T06:47:52Z</dc:date>
    </item>
    <item>
      <title>Re: Appropriate select querry needed</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/appropriate-select-querry-needed/m-p/6497938#M1421260</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;Check with this one....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT  PLNNR
             PLNKN
             ARBID
             WERKS
             BMSCH
             VGE02
             max(VGW02)
       FROM PLPO
       INTO TABLE IT_PLPO
     up to 1 rows
      FOR ALL ENTRIES IN IT_CRHD
      WHERE WERKS EQ IT_CRHD-WERKS    AND ARBID EQ IT_CRHD-OBJID     
         AND PLNTY EQ 'N'.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sid&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Jan 2010 06:53:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/appropriate-select-querry-needed/m-p/6497938#M1421260</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-01-08T06:53:56Z</dc:date>
    </item>
    <item>
      <title>Re: Appropriate select querry needed</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/appropriate-select-querry-needed/m-p/6497939#M1421261</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

SELECT  Single PLNNR
             PLNKN
             ARBID
             WERKS
             BMSCH
             VGE02 
      max(VGW02)
       FROM PLPO
       INTO TABLE IT_PLPO
      FOR ALL ENTRIES IN IT_CRHD
      WHERE WERKS EQ IT_CRHD-WERKS    AND ARBID EQ IT_CRHD-OBJID     
         AND PLNTY EQ 'N'.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Jan 2010 06:55:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/appropriate-select-querry-needed/m-p/6497939#M1421261</guid>
      <dc:creator>GauthamV</dc:creator>
      <dc:date>2010-01-08T06:55:34Z</dc:date>
    </item>
    <item>
      <title>Re: Appropriate select querry needed</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/appropriate-select-querry-needed/m-p/6497940#M1421262</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Karthick,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unfortunately aggregate functions (with exception to COUNT * ) are not supported with FOR ALL ENTRIES. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SAP documentation says: &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;If the addition FOR ALL ENTRIES is used in front of WHERE, or if cluster or pool tables are listed after FROM, no other aggregate expressions apart from COUNT( * ) can be used. &lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also: &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;The addition FOR ALL ENTRIES is only possible before WHERE conditions of the SELECT statement. &lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You have to select all the records, then sort based on the column you want &amp;amp; read the record. I donot think there is any alternative to this &lt;SPAN __jive_emoticon_name="sad"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Suhas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Suhas Saha on Jan 8, 2010 12:28 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Jan 2010 06:56:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/appropriate-select-querry-needed/m-p/6497940#M1421262</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2010-01-08T06:56:12Z</dc:date>
    </item>
    <item>
      <title>Re: Appropriate select querry needed</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/appropriate-select-querry-needed/m-p/6497941#M1421263</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Gautham,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried the above logic already but I am getting error message&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;the addition FOR ALL ENTRIES excludes all aggregate functions with the exception
of COUNT(*) as the single element of the SELECT clause&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Even I tried by using&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;loop at it_crhd into wa_crhd.
 SELECT  PLNNR
            PLNKN
            ARBID
            WERKS
            BMSCH
            VGE02
       MAX( VGW02 )
      FROM PLPO
      INTO CORRESPONDING FIELDS OF TABLE IT_PLPO
WHERE WERKS EQ WA_CRHD-WERKS AND ARBID EQ WA_CRHD-OBJID
        AND PLNTY EQ 'N'.

append wa_plpo into it_plpo.
endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regds&lt;/P&gt;&lt;P&gt;Karthik&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Jan 2010 07:06:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/appropriate-select-querry-needed/m-p/6497941#M1421263</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-01-08T07:06:56Z</dc:date>
    </item>
    <item>
      <title>Re: Appropriate select querry needed</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/appropriate-select-querry-needed/m-p/6497942#M1421264</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; the addition FOR ALL ENTRIES excludes all aggregate functions with the exception&lt;/P&gt;&lt;P&gt;&amp;gt; of COUNT(*) as the single element of the SELECT clause&lt;/P&gt;&lt;P&gt;&amp;gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hello Karthick,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have already pointed it out MAX will not work with FAE. Please take the pain to read the SAP documentation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AFAIK you have no shortcut technique, you gotto select all records &amp;amp; then fetch the MAX value. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Suhas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Jan 2010 07:21:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/appropriate-select-querry-needed/m-p/6497942#M1421264</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2010-01-08T07:21:47Z</dc:date>
    </item>
    <item>
      <title>Re: Appropriate select querry needed</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/appropriate-select-querry-needed/m-p/6497943#M1421265</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI Suhas,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanx for your valueble advice&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rgds&lt;/P&gt;&lt;P&gt;Karthik&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Jan 2010 07:35:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/appropriate-select-querry-needed/m-p/6497943#M1421265</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-01-08T07:35:11Z</dc:date>
    </item>
  </channel>
</rss>

