<?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: Problem with the following SQL statement in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-the-following-sql-statement/m-p/956107#M66337</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;pooled and cluster tables (like BSEG, KONV, ...) have some restrictions (no aggregate functions, no inner join...)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can use the following statements&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: begin of total_tab occurs 0,
      KWERT type KONV-KWERT,
      end of total_tab,

      wa like line of total_tab.

DATA: total_shipping TYPE p DECIMALS 2.

SELECT KWERT
INTO table total_tab
FROM KONV
WHERE KNUMV = '0000001104' and KSCHL = 'ZKF0'.

loop at total_tab into wa.
  at first.
    sum.
    total_shipping = wa-kwert.
    exit.
  endat.
endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 01 Aug 2005 10:45:45 GMT</pubDate>
    <dc:creator>manuel_bassani</dc:creator>
    <dc:date>2005-08-01T10:45:45Z</dc:date>
    <item>
      <title>Problem with the following SQL statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-the-following-sql-statement/m-p/956104#M66334</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;When I goto Activate the ABAP program the following error pops up for the SQL statement below;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: total_shipping TYPE p DECIMALS 2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT SUM( KWERT )&lt;/P&gt;&lt;P&gt;  INTO total_shipping&lt;/P&gt;&lt;P&gt; FROM KONV&lt;/P&gt;&lt;P&gt;WHERE KNUMV = '0000001104' and KSCHL = 'ZKF0'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Error - "Aggregate functions and the addition DISTINCT are not supported in field lists for pooled and cluster tables."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What could be the solution be?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kishan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Aug 2005 10:36:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-the-following-sql-statement/m-p/956104#M66334</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-08-01T10:36:52Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with the following SQL statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-the-following-sql-statement/m-p/956105#M66335</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Get the records in an internal table Add them or use the collect statement. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Shekhar Kulkarni&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Aug 2005 10:39:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-the-following-sql-statement/m-p/956105#M66335</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-08-01T10:39:38Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with the following SQL statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-the-following-sql-statement/m-p/956106#M66336</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;Define total_shipping as&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: total_shipping LIKE KONV-KWERT. &lt;/P&gt;&lt;P&gt;OR&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;DATA: total_shipping LIKE KONV-KAWRT&amp;lt;/b&amp;gt;. as sometimes while doing SUM it will over flow so inorder to avoid that use this data declaration.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT SUM( KWERT )&lt;/P&gt;&lt;P&gt;INTO total_shipping&lt;/P&gt;&lt;P&gt;FROM KONV&lt;/P&gt;&lt;P&gt;WHERE KNUMV = '0000001104' and KSCHL = 'ZKF0'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try this one.&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Aug 2005 10:44:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-the-following-sql-statement/m-p/956106#M66336</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-08-01T10:44:47Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with the following SQL statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-the-following-sql-statement/m-p/956107#M66337</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;pooled and cluster tables (like BSEG, KONV, ...) have some restrictions (no aggregate functions, no inner join...)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can use the following statements&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: begin of total_tab occurs 0,
      KWERT type KONV-KWERT,
      end of total_tab,

      wa like line of total_tab.

DATA: total_shipping TYPE p DECIMALS 2.

SELECT KWERT
INTO table total_tab
FROM KONV
WHERE KNUMV = '0000001104' and KSCHL = 'ZKF0'.

loop at total_tab into wa.
  at first.
    sum.
    total_shipping = wa-kwert.
    exit.
  endat.
endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Aug 2005 10:45:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-the-following-sql-statement/m-p/956107#M66337</guid>
      <dc:creator>manuel_bassani</dc:creator>
      <dc:date>2005-08-01T10:45:45Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with the following SQL statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-the-following-sql-statement/m-p/956108#M66338</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Table KONV is a cluster table. SUM you can do only for transparent tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: total_shipping TYPE p DECIMALS 2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT KWERT FROM KONV WHERE KNUMV = '0000001104' and KSCHL = 'ZKF0'.&lt;/P&gt;&lt;P&gt;total_shipping = total_shipping + KONV-KWERT.&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Aug 2005 10:47:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-the-following-sql-statement/m-p/956108#M66338</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-08-01T10:47:27Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with the following SQL statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-the-following-sql-statement/m-p/956109#M66339</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;Try this one&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT zzz_test .

TABLES: konv.

TYPES: begin of ty_ship,
  kwert LIKE konv-kwert,
 end of ty_ship.
 DATA: total_shipping LIKE konv-kawrt.

 DATA: i_ship type standard table of ty_ship,
       w_ship type ty_ship.

SELECT kwert
INTO table i_ship
FROM konv
WHERE knumv = '0000001104' AND kschl = 'ZKF0'.

IF sy-subrc = 0.
clear total_shipping.
Loop at i_ship into w_ship.
 total_shipping = w_ship-kwert + total_shipping.
clear w_ship.
endloop.
ENDIF.
WRITE: / total_shipping.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Manually insert some values in debugging mode and check it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Aug 2005 10:58:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-the-following-sql-statement/m-p/956109#M66339</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-08-01T10:58:10Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with the following SQL statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-the-following-sql-statement/m-p/956110#M66340</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;data itab type standard table of konv.&lt;/P&gt;&lt;P&gt;data wa type konv.&lt;/P&gt;&lt;P&gt;DATA: total_shipping TYPE p DECIMALS 2 value 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from konv into table itab&lt;/P&gt;&lt;P&gt;WHERE KNUMV = '0000001104' and KSCHL = 'ZKF0'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab into wa.&lt;/P&gt;&lt;P&gt;total_shipping = total_shipping + wa-kwert.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;write total_shipping.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Aug 2005 10:58:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-the-following-sql-statement/m-p/956110#M66340</guid>
      <dc:creator>jayanthi_jayaraman</dc:creator>
      <dc:date>2005-08-01T10:58:37Z</dc:date>
    </item>
  </channel>
</rss>

