<?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 Internal Table Counting in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-counting/m-p/2886593#M678094</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to be able to SELECT COUNT(*) from an internal table where a certain&lt;/P&gt;&lt;P&gt;condition exists i.e. COL1 = 'A' like you would do with a normal database table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anyone have any tricks up their sleeves to do this???&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Andy&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 26 Sep 2007 07:18:52 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-09-26T07:18:52Z</dc:date>
    <item>
      <title>Internal Table Counting</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-counting/m-p/2886593#M678094</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to be able to SELECT COUNT(*) from an internal table where a certain&lt;/P&gt;&lt;P&gt;condition exists i.e. COL1 = 'A' like you would do with a normal database table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anyone have any tricks up their sleeves to do this???&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Andy&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Sep 2007 07:18:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-counting/m-p/2886593#M678094</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-26T07:18:52Z</dc:date>
    </item>
    <item>
      <title>Re: Internal Table Counting</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-counting/m-p/2886594#M678095</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;If you want to find the maximum, minimum, sum and average value or the count of a database column, use a select list with aggregate functions instead of computing the aggregates yourself.  Some of the Aggregate functions allowed in SAP are  MAX, MIN, AVG, SUM, COUNT, COUNT( * )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Consider the following extract.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Maxno = 0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Select * from zflight where airln = &amp;#145;LF&amp;#146; and cntry = &amp;#145;IN&amp;#146;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Check zflight-fligh &amp;gt; maxno.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Maxno = zflight-fligh.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Endselect.&lt;/P&gt;&lt;P&gt;The  above mentioned code can be much more optimized by using the following code.&lt;/P&gt;&lt;P&gt; Select max( fligh ) from zflight into maxno where airln = &amp;#145;LF&amp;#146; and cntry = &amp;#145;IN&amp;#146;. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to count number of records then &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LV_COUNT = 0.&lt;/P&gt;&lt;P&gt;  LOOP  AT IT_OUTPUT INTO WA_OUTPUT.&lt;/P&gt;&lt;P&gt;    LV_COUNT = LV_COUNT + 1.&lt;/P&gt;&lt;P&gt;    WA_OUTPUT-COUNT = LV_COUNT.&lt;/P&gt;&lt;P&gt;    APPEND WA_OUTPUT TO IT_OUTPUT_1.&lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt;  REFRESH IT_OUTPUT.&lt;/P&gt;&lt;P&gt;  IT_OUTPUT = IT_OUTPUT_1.&lt;/P&gt;&lt;P&gt;reward if usefull&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Sep 2007 07:21:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-counting/m-p/2886594#M678095</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-26T07:21:38Z</dc:date>
    </item>
    <item>
      <title>Re: Internal Table Counting</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-counting/m-p/2886595#M678096</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We cannot directly have the count.&lt;/P&gt;&lt;P&gt;Check these options -&lt;/P&gt;&lt;P&gt;You cannot find the count in one direct statement. You will have to use the count() in your select, or if that is not possible, then:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Easy option:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab where field1 = condition1.&lt;/P&gt;&lt;P&gt;counter = counter + 1.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A lesser easy way, and not always feasible:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;itab_copy[] = itab[].&lt;/P&gt;&lt;P&gt;delete itab_copy where field1 NE condition1.&lt;/P&gt;&lt;P&gt;describe table itab_copy lines lv_lines.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;~ As found in forum&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amit&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward all helpful replies.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Sep 2007 07:22:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-counting/m-p/2886595#M678096</guid>
      <dc:creator>amit_khare</dc:creator>
      <dc:date>2007-09-26T07:22:36Z</dc:date>
    </item>
    <item>
      <title>Re: Internal Table Counting</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-counting/m-p/2886596#M678097</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi&lt;/P&gt;&lt;P&gt;good&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;go through this link&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/dba09d35c111d1829f0000e829fbfe/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/dba09d35c111d1829f0000e829fbfe/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;mrutyun^&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Sep 2007 07:23:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-counting/m-p/2886596#M678097</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-26T07:23:46Z</dc:date>
    </item>
    <item>
      <title>Re: Internal Table Counting</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-counting/m-p/2886597#M678098</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Use&lt;/P&gt;&lt;P&gt;loop at itab where field1 = condition1 (e.g col1 = 'A').&lt;/P&gt;&lt;P&gt;counter = counter + 1.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If it is helpful pls rewards points.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Srimanta&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Sep 2007 07:28:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-counting/m-p/2886597#M678098</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-26T07:28:11Z</dc:date>
    </item>
  </channel>
</rss>

