<?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: Aggregate Functions in SELECT in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/aggregate-functions-in-select/m-p/1106007#M104804</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not sure what you mean by 'not working', but you can try something like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
* select data: parked documents in value type 54 (invoice) --------
  select  fmifiit~knbelnr bkpf~bstat
      count( distinct fmifiit~fmbelnr )
   into (wa_error-belnr, wa_error-bstat, wa_error-count)
   from fmifiit inner join bkpf
      on ( fmifiit~bukrs = bkpf~bukrs and
           fmifiit~kngjahr = bkpf~gjahr and
           fmifiit~knbelnr = bkpf~belnr )
      where fmifiit~knbelnr in s_belnr
        and fmifiit~bukrs = p_bukrs
        and fmifiit~kngjahr = p_gjahr
        and ( fmifiit~wrttp = '54' or
              fmifiit~wrttp = '57' or
              fmifiit~wrttp = '66' )
        and bkpf~bukrs = p_bukrs
        and bkpf~gjahr = p_gjahr
        and bkpf~belnr in s_belnr
        and bkpf~budat in s_budat
        and ( bkpf~bstat = 'V' or bkpf~bstat = 'W' or bkpf~bstat = 'Z' )
      group by fmifiit~knbelnr
               bkpf~bstat
      order by fmifiit~knbelnr.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 25 Oct 2005 15:51:45 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2005-10-25T15:51:45Z</dc:date>
    <item>
      <title>Aggregate Functions in SELECT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/aggregate-functions-in-select/m-p/1106005#M104802</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Friends,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  Is it possible to have an aggregate function while using Inner join and GROUP BY? Its not working for me. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Prompt replies would be rewarded.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tamilarasan.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Tamilarasan Lakshmanan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Oct 2005 15:34:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/aggregate-functions-in-select/m-p/1106005#M104802</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-10-25T15:34:36Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate Functions in SELECT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/aggregate-functions-in-select/m-p/1106006#M104803</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm seeing the same.  In my sample program it is aggregating on the first column, but not collecting the quantity in the second column.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

report zrich_0002.

data: begin of itab occurs 0,
      gltrp type afko-gltrp,
      psmng type afpo-psmng,
      end of itab.

select-options: s_gltrp for itab-gltrp.


select afko~gltrp  sum( afpo~psmng )
      into corresponding fields of table itab
             from afko
                  inner join afpo
                     on afko~aufnr = afpo~aufnr
                           where afko~gltrp in s_gltrp
                                group by afko~gltrp.

check sy-subrc = 0.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Oct 2005 15:51:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/aggregate-functions-in-select/m-p/1106006#M104803</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2005-10-25T15:51:11Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate Functions in SELECT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/aggregate-functions-in-select/m-p/1106007#M104804</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not sure what you mean by 'not working', but you can try something like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
* select data: parked documents in value type 54 (invoice) --------
  select  fmifiit~knbelnr bkpf~bstat
      count( distinct fmifiit~fmbelnr )
   into (wa_error-belnr, wa_error-bstat, wa_error-count)
   from fmifiit inner join bkpf
      on ( fmifiit~bukrs = bkpf~bukrs and
           fmifiit~kngjahr = bkpf~gjahr and
           fmifiit~knbelnr = bkpf~belnr )
      where fmifiit~knbelnr in s_belnr
        and fmifiit~bukrs = p_bukrs
        and fmifiit~kngjahr = p_gjahr
        and ( fmifiit~wrttp = '54' or
              fmifiit~wrttp = '57' or
              fmifiit~wrttp = '66' )
        and bkpf~bukrs = p_bukrs
        and bkpf~gjahr = p_gjahr
        and bkpf~belnr in s_belnr
        and bkpf~budat in s_budat
        and ( bkpf~bstat = 'V' or bkpf~bstat = 'W' or bkpf~bstat = 'Z' )
      group by fmifiit~knbelnr
               bkpf~bstat
      order by fmifiit~knbelnr.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Oct 2005 15:51:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/aggregate-functions-in-select/m-p/1106007#M104804</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-10-25T15:51:45Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate Functions in SELECT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/aggregate-functions-in-select/m-p/1106008#M104805</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tamilarasan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_47x200/helpdata/en/44/78baf6f7d2424fa78fd67860a18b26/frameset.htm" target="test_blank"&gt;http://help.sap.com/saphelp_47x200/helpdata/en/44/78baf6f7d2424fa78fd67860a18b26/frameset.htm&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Oct 2005 15:52:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/aggregate-functions-in-select/m-p/1106008#M104805</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-10-25T15:52:51Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate Functions in SELECT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/aggregate-functions-in-select/m-p/1106009#M104806</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, I got my sample working now.  Check it out.  I didn't like the "into corresponding fields"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

report zrich_0002.

data: begin of itab occurs 0,
      gltrp type afko-gltrp,
      psmng type afpo-psmng,
      end of itab.

select-options: s_gltrp for itab-gltrp.


select afko~gltrp  sum( afpo~psmng )
      into  table itab
             from afko
                  inner join afpo
                     on afko~aufnr = afpo~aufnr
                           where afko~gltrp in s_gltrp
                                group by afko~gltrp.

check sy-subrc = 0.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Oct 2005 15:57:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/aggregate-functions-in-select/m-p/1106009#M104806</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2005-10-25T15:57:16Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate Functions in SELECT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/aggregate-functions-in-select/m-p/1106010#M104807</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please make sure to award points for any helpful answers that might have helped you.  If your problem is solved, please mark this post as solved.  Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Oct 2005 17:22:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/aggregate-functions-in-select/m-p/1106010#M104807</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2005-10-25T17:22:56Z</dc:date>
    </item>
  </channel>
</rss>

