<?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: how to use the SQL group by functionality on internal table. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-the-sql-group-by-functionality-on-internal-table/m-p/5940188#M1334478</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Nitin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is better to select all data into internal table and do the processing to get the sum or other calculation. This is better that using SELECT (MAX) etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The reason is, you are performing operation at abap level, not at database level.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Rupali.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 22 Jul 2009 22:30:19 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-07-22T22:30:19Z</dc:date>
    <item>
      <title>how to use the SQL group by functionality on internal table.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-the-sql-group-by-functionality-on-internal-table/m-p/5940185#M1334475</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;can any body explain me to how to use the SQL group by functionality on internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i want to use the aggregate function on internal table using the different columns of the table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in SQL we use &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select werks matnr maktx extwg lgort umren meins sum(menge) sum(prd_wat)&lt;/P&gt;&lt;P&gt;from   itab&lt;/P&gt;&lt;P&gt;group by werks matnr maktx extwg lgort umren meins&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;how this functionality will work on internal table ? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;similarly if i want to use the max, min or average of internal table column.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i just give you the sql statement above.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;also just give me the some different ways to do this work.....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Nitin Varshney&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jul 2009 11:56:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-the-sql-group-by-functionality-on-internal-table/m-p/5940185#M1334475</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-21T11:56:01Z</dc:date>
    </item>
    <item>
      <title>Re: how to use the SQL group by functionality on internal table.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-the-sql-group-by-functionality-on-internal-table/m-p/5940186#M1334476</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;Group by functionality is only avaliable for ABAP SQL's and not for internal table but you can use AT..ENDAT statement in&lt;/P&gt;&lt;P&gt;LOOP AT ITAB...ENDLOOP to simulate the group by functionality.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Following are the various options available:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT &amp;lt;itab&amp;gt;.&lt;/P&gt;&lt;P&gt;  AT FIRST. ... ENDAT.&lt;/P&gt;&lt;P&gt;    AT NEW &amp;lt;f1&amp;gt;. ...... ENDAT.&lt;/P&gt;&lt;P&gt;      AT NEW &amp;lt;f2 &amp;gt;. ...... ENDAT.&lt;/P&gt;&lt;P&gt;        ....... &lt;/P&gt;&lt;P&gt;          &amp;lt;single line processing&amp;gt;&lt;/P&gt;&lt;P&gt;....... &lt;/P&gt;&lt;P&gt;      AT END OF &amp;lt;f2&amp;gt;. ... ENDAT.&lt;/P&gt;&lt;P&gt;    AT END OF &amp;lt;f1&amp;gt;. ... ENDAT.&lt;/P&gt;&lt;P&gt;  AT LAST. .... ENDAT.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For more information youn can refer to following link:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw04/helpdata/EN/fc/eb381a358411d1829f0000e829fbfe/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw04/helpdata/EN/fc/eb381a358411d1829f0000e829fbfe/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, for other aggregate function like min, max, sum you need to do processing using LOOP AT &amp;lt;ITAB&amp;gt;...ENDLOOP&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;No standard commands are avaliable in SAP ABAP for above functions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Augustin.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jul 2009 12:21:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-the-sql-group-by-functionality-on-internal-table/m-p/5940186#M1334476</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-21T12:21:16Z</dc:date>
    </item>
    <item>
      <title>Re: how to use the SQL group by functionality on internal table.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-the-sql-group-by-functionality-on-internal-table/m-p/5940187#M1334477</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You would use the following code replace SQL group functionality:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT T INTO WA_T. &lt;/P&gt;&lt;P&gt;  AT FIRST. &lt;/P&gt;&lt;P&gt;    SUM. &lt;/P&gt;&lt;P&gt;    ...&lt;/P&gt;&lt;P&gt;  ENDAT. &lt;/P&gt;&lt;P&gt;  ...&lt;/P&gt;&lt;P&gt;  AT END OF fielda. &lt;/P&gt;&lt;P&gt;    SUM. &lt;/P&gt;&lt;P&gt;    ...&lt;/P&gt;&lt;P&gt;  ENDAT. &lt;/P&gt;&lt;P&gt;ENDLOOP. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;About more information please refer to abap online help for ( AT - Control breaks with internal tables )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that:&lt;/P&gt;&lt;P&gt;you should sort the internal table by the  group field key when using AT control statement within loop ...endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Jul 2009 06:25:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-the-sql-group-by-functionality-on-internal-table/m-p/5940187#M1334477</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-22T06:25:25Z</dc:date>
    </item>
    <item>
      <title>Re: how to use the SQL group by functionality on internal table.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-the-sql-group-by-functionality-on-internal-table/m-p/5940188#M1334478</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Nitin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is better to select all data into internal table and do the processing to get the sum or other calculation. This is better that using SELECT (MAX) etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The reason is, you are performing operation at abap level, not at database level.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Rupali.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Jul 2009 22:30:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-the-sql-group-by-functionality-on-internal-table/m-p/5940188#M1334478</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-22T22:30:19Z</dc:date>
    </item>
    <item>
      <title>Re: how to use the SQL group by functionality on internal table.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-the-sql-group-by-functionality-on-internal-table/m-p/5940189#M1334479</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Nitin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can also use COLLECT statement into another internal table for aggregating the data. This will aggregate all the Key Figures (Amount, Quantity etc numeric fields). But this might be slower in some cases, hence it is mandatory to SORT the Source internal table before using the COLLECT statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Eg.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT werks matnr maktx extwg lgort umren meins menge prd_wat&lt;/P&gt;&lt;P&gt; from DATABASE TABLE&lt;/P&gt;&lt;P&gt; INTO TABLE itab1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="3" type="ul"&gt;&lt;P&gt;Important&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;SORT itab1 BY werks matnr maktx extwg lgort umren meins.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop itab1 into wa1.&lt;/P&gt;&lt;P&gt;   collect wa1 into itab2.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLEAR itab1[].&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Chathia.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jul 2009 04:31:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-the-sql-group-by-functionality-on-internal-table/m-p/5940189#M1334479</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-23T04:31:42Z</dc:date>
    </item>
    <item>
      <title>Re: how to use the SQL group by functionality on internal table.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-the-sql-group-by-functionality-on-internal-table/m-p/5940190#M1334480</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;By useing AT NEW and AT LAST events in a LOOP of internal table you get all group of values together&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jul 2009 04:48:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-the-sql-group-by-functionality-on-internal-table/m-p/5940190#M1334480</guid>
      <dc:creator>former_member206439</dc:creator>
      <dc:date>2009-07-23T04:48:40Z</dc:date>
    </item>
    <item>
      <title>Re: how to use the SQL group by functionality on internal table.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-the-sql-group-by-functionality-on-internal-table/m-p/5940191#M1334481</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi chathia,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can i get the max, min or average fuctionality by using the collect statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Nitin Varshney&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jul 2009 12:27:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-the-sql-group-by-functionality-on-internal-table/m-p/5940191#M1334481</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-23T12:27:21Z</dc:date>
    </item>
    <item>
      <title>Re: how to use the SQL group by functionality on internal table.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-the-sql-group-by-functionality-on-internal-table/m-p/5940192#M1334482</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi naresh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can u please explain how at new &amp;amp; at last work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;actually i have done it, but it is not clear.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;how i can get sum or min max or average by grouping of different columns( more than 4 or 5 column in grouping)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;means i want grouping the data on the basis of 4-5 columns.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;like just i have told in my sql statement in last conversation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;pls clear.......&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Nitin Varshney&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jul 2009 12:32:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-the-sql-group-by-functionality-on-internal-table/m-p/5940192#M1334482</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-23T12:32:47Z</dc:date>
    </item>
    <item>
      <title>Re: how to use the SQL group by functionality on internal table.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-the-sql-group-by-functionality-on-internal-table/m-p/5940193#M1334483</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Nitin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The COLLECT statement is used only for SUM operation. You will not be able to do MAX, MIN etc using this statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Chathia.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jul 2009 12:33:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-the-sql-group-by-functionality-on-internal-table/m-p/5940193#M1334483</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-23T12:33:41Z</dc:date>
    </item>
    <item>
      <title>Re: how to use the SQL group by functionality on internal table.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-the-sql-group-by-functionality-on-internal-table/m-p/5940194#M1334484</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can u please explain me.........&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;how i can get the min max or average on internal table using multiple column grouping.........&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Nitin Varshney&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jul 2009 12:38:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-the-sql-group-by-functionality-on-internal-table/m-p/5940194#M1334484</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-23T12:38:28Z</dc:date>
    </item>
  </channel>
</rss>

