<?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: count from an internal table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/count-from-an-internal-table/m-p/2845504#M666581</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;U take a variable for divison.  when increasing the counter u check the condition with variable if variable is equal to previous variable then don't increase the counter.&lt;/P&gt;&lt;P&gt;else increase the counter and every time in the loop u update divison value with latest divison value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rewardpoints if useful.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;(YUGANDHAR.P)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 28 Sep 2007 07:51:06 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-09-28T07:51:06Z</dc:date>
    <item>
      <title>count from an internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/count-from-an-internal-table/m-p/2845500#M666577</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;In my internal table, I have multiple entries for different divisions.&lt;/P&gt;&lt;P&gt;I need the count of all the distinct divisions.&lt;/P&gt;&lt;P&gt;For example: I have &lt;/P&gt;&lt;P&gt;2 records for division 20,&lt;/P&gt;&lt;P&gt;2 records for division 30, and&lt;/P&gt;&lt;P&gt;2 records for division 40.&lt;/P&gt;&lt;P&gt;then in this case the count value should be 3.&lt;/P&gt;&lt;P&gt;Can anyone suggest any logic for this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Points will be rewarded for correct answer.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Sep 2007 07:45:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/count-from-an-internal-table/m-p/2845500#M666577</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-28T07:45:25Z</dc:date>
    </item>
    <item>
      <title>Re: count from an internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/count-from-an-internal-table/m-p/2845501#M666578</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;sort itab acccording to division.&lt;/P&gt;&lt;P&gt;count = 0.&lt;/P&gt;&lt;P&gt;loop at itab.&lt;/P&gt;&lt;P&gt;At new division&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;count = count +1.&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;regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Sep 2007 07:47:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/count-from-an-internal-table/m-p/2845501#M666578</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-28T07:47:36Z</dc:date>
    </item>
    <item>
      <title>Re: count from an internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/count-from-an-internal-table/m-p/2845502#M666579</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 the control break statements and achive this count&lt;/P&gt;&lt;P&gt;Sort the itab by DIVISION.&lt;/P&gt;&lt;P&gt;Use AT NEW and AT END OF events and use a counter variable and get it&lt;/P&gt;&lt;P&gt;see the sample code for this control events&lt;/P&gt;&lt;P&gt;All this AT NEW, AT FIRST, AT END OF and AT LAST are called control break statements of Internal tables and are used to calculate the TOTALS based on sertain key fields in that internal table&lt;/P&gt;&lt;P&gt;FIrst to use these statements the ITAB has to be sorted by the key fields on whcih you need the SUM of the fields.&lt;/P&gt;&lt;P&gt;Some time you will get * when mopving data from this int table to other table using these commands&lt;/P&gt;&lt;P&gt;so you have to use&lt;/P&gt;&lt;P&gt;READ TABLE ITAB INDEX SY-TABIX in AT..ENDAT..if you are using other fields between them&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: sflight_tab TYPE SORTED TABLE OF sflight &lt;/P&gt;&lt;P&gt;                  WITH UNIQUE KEY carrid connid fldate, &lt;/P&gt;&lt;P&gt;      sflight_wa  LIKE LINE OF sflight_tab. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * &lt;/P&gt;&lt;P&gt;       FROM sflight &lt;/P&gt;&lt;P&gt;       INTO TABLE sflight_tab. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT sflight_tab INTO sflight_wa. &lt;/P&gt;&lt;P&gt;  AT NEW connid. &lt;/P&gt;&lt;P&gt;    WRITE: / sflight_wa-carrid, &lt;/P&gt;&lt;P&gt;             sflight_wa-connid. &lt;/P&gt;&lt;P&gt;    ULINE. &lt;/P&gt;&lt;P&gt;  ENDAT. &lt;/P&gt;&lt;P&gt;  WRITE: / sflight_wa-fldate, &lt;/P&gt;&lt;P&gt;           sflight_wa-seatsocc. &lt;/P&gt;&lt;P&gt;  AT END OF connid. &lt;/P&gt;&lt;P&gt;    SUM. &lt;/P&gt;&lt;P&gt;    ULINE. &lt;/P&gt;&lt;P&gt;    WRITE: / 'Sum', &lt;/P&gt;&lt;P&gt;              sflight_wa-seatsocc UNDER sflight_wa-seatsocc. &lt;/P&gt;&lt;P&gt;    SKIP. &lt;/P&gt;&lt;P&gt;  ENDAT. &lt;/P&gt;&lt;P&gt;  AT END OF carrid. &lt;/P&gt;&lt;P&gt;    SUM. &lt;/P&gt;&lt;P&gt;    ULINE. &lt;/P&gt;&lt;P&gt;    WRITE: / 'Carrier Sum', &lt;/P&gt;&lt;P&gt;              sflight_wa-seatsocc UNDER sflight_wa-seatsocc. &lt;/P&gt;&lt;P&gt;    NEW-PAGE. &lt;/P&gt;&lt;P&gt;  ENDAT. &lt;/P&gt;&lt;P&gt;  AT LAST. &lt;/P&gt;&lt;P&gt;    SUM. &lt;/P&gt;&lt;P&gt;    WRITE: / 'Overall Sum', &lt;/P&gt;&lt;P&gt;              sflight_wa-seatsocc UNDER sflight_wa-seatsocc. &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;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Anji&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Sep 2007 07:48:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/count-from-an-internal-table/m-p/2845502#M666579</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-28T07:48:10Z</dc:date>
    </item>
    <item>
      <title>Re: count from an internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/count-from-an-internal-table/m-p/2845503#M666580</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DEscribe table itab lines l.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;pls reward if helpful.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Sep 2007 07:48:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/count-from-an-internal-table/m-p/2845503#M666580</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-28T07:48:27Z</dc:date>
    </item>
    <item>
      <title>Re: count from an internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/count-from-an-internal-table/m-p/2845504#M666581</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;U take a variable for divison.  when increasing the counter u check the condition with variable if variable is equal to previous variable then don't increase the counter.&lt;/P&gt;&lt;P&gt;else increase the counter and every time in the loop u update divison value with latest divison value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rewardpoints if useful.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;(YUGANDHAR.P)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Sep 2007 07:51:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/count-from-an-internal-table/m-p/2845504#M666581</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-28T07:51:06Z</dc:date>
    </item>
  </channel>
</rss>

