<?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: select count( * ) command at internal tables in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-count-command-at-internal-tables/m-p/3855685#M926846</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Rather than loop through the table you could try this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your table is itab1.  Define a temporary table, itab2, of the same type.  NOTE: neither table with header lines.  &lt;STRONG&gt;cond&lt;/STRONG&gt; is the condition you want the records to meet.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;itab2 = itab1.
DELETE itab2 WHERE NOT cond.
no_of_recs_meeting_cond = lines( itab2 ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not terribly memory efficient, but it could be a little quicker than looping.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;matt&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 13 May 2008 18:11:30 GMT</pubDate>
    <dc:creator>matt</dc:creator>
    <dc:date>2008-05-13T18:11:30Z</dc:date>
    <item>
      <title>select count( * ) command at internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-count-command-at-internal-tables/m-p/3855680#M926841</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;it is not possible to use a select quiry at internal tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like determine the number of person with a where&lt;/P&gt;&lt;P&gt;condition at an internal table.  How does it work ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I cant say :&lt;/P&gt;&lt;P&gt; select count( * ) from xxx into xxxxxxx&lt;/P&gt;&lt;P&gt;                  where xx= xx.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What else can I do ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;ertas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 May 2008 17:10:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-count-command-at-internal-tables/m-p/3855680#M926841</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-13T17:10:20Z</dc:date>
    </item>
    <item>
      <title>Re: select count( * ) command at internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-count-command-at-internal-tables/m-p/3855681#M926842</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi check this..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PARAMETERS: p_carrid TYPE sbook-carrid, &lt;/P&gt;&lt;P&gt;            p_connid TYPE sbook-connid. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPES: BEGIN OF sbook_type, &lt;/P&gt;&lt;P&gt;         fldate  TYPE sbook-fldate, &lt;/P&gt;&lt;P&gt;         smoker  TYPE sbook-smoker, &lt;/P&gt;&lt;P&gt;         smk_cnt TYPE i, &lt;/P&gt;&lt;P&gt;       END OF sbook_type. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA sbook_tab TYPE TABLE OF sbook_type. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT fldate smoker COUNT( * ) AS smk_cnt &lt;/P&gt;&lt;P&gt;       FROM sbook &lt;/P&gt;&lt;P&gt;       INTO CORRESPONDING FIELDS OF TABLE sbook_tab &lt;/P&gt;&lt;P&gt;       WHERE connid = p_connid &lt;/P&gt;&lt;P&gt;       GROUP BY carrid fldate smoker &lt;/P&gt;&lt;P&gt;       HAVING carrid = p_carrid &lt;/P&gt;&lt;P&gt;       ORDER BY fldate smoker&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;venkat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 May 2008 17:11:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-count-command-at-internal-tables/m-p/3855681#M926842</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-13T17:11:16Z</dc:date>
    </item>
    <item>
      <title>Re: select count( * ) command at internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-count-command-at-internal-tables/m-p/3855682#M926843</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If the data is in an internal table you would have to count it manually.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data: lv_count type i.

clear lv_count.
loop at itab where some_field = 'ABC'.
  lv_count = lv_count + 1.
endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&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, 13 May 2008 17:15:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-count-command-at-internal-tables/m-p/3855682#M926843</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2008-05-13T17:15:18Z</dc:date>
    </item>
    <item>
      <title>Re: select count( * ) command at internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-count-command-at-internal-tables/m-p/3855683#M926844</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;Use a normal select.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The system variable sy-dbcnt has the number of records from last select statement.&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;Fernando&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 May 2008 17:21:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-count-command-at-internal-tables/m-p/3855683#M926844</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-13T17:21:54Z</dc:date>
    </item>
    <item>
      <title>Re: select count( * ) command at internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-count-command-at-internal-tables/m-p/3855684#M926845</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;Make queries to internal tables it's not possible.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your specific case, to know the number of rows with a specific WHERE condition, you can do it this way:&lt;/P&gt;&lt;P&gt;- LOOP at itab WHERE condition ...&lt;/P&gt;&lt;P&gt;- after the loop check variable sy-tabix: it return how many lines where found.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards.&lt;/P&gt;&lt;P&gt;Valter Oliveira.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 May 2008 17:22:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-count-command-at-internal-tables/m-p/3855684#M926845</guid>
      <dc:creator>valter_oliveira</dc:creator>
      <dc:date>2008-05-13T17:22:53Z</dc:date>
    </item>
    <item>
      <title>Re: select count( * ) command at internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-count-command-at-internal-tables/m-p/3855685#M926846</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Rather than loop through the table you could try this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your table is itab1.  Define a temporary table, itab2, of the same type.  NOTE: neither table with header lines.  &lt;STRONG&gt;cond&lt;/STRONG&gt; is the condition you want the records to meet.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;itab2 = itab1.
DELETE itab2 WHERE NOT cond.
no_of_recs_meeting_cond = lines( itab2 ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not terribly memory efficient, but it could be a little quicker than looping.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;matt&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 May 2008 18:11:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-count-command-at-internal-tables/m-p/3855685#M926846</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2008-05-13T18:11:30Z</dc:date>
    </item>
    <item>
      <title>Re: select count( * ) command at internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-count-command-at-internal-tables/m-p/3855686#M926847</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think LINES() is available as of release 6.10, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; a®&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 May 2008 18:19:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-count-command-at-internal-tables/m-p/3855686#M926847</guid>
      <dc:creator>former_member194669</dc:creator>
      <dc:date>2008-05-13T18:19:14Z</dc:date>
    </item>
  </channel>
</rss>

