<?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: Mutiple Counter variables in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/mutiple-counter-variables/m-p/11648438#M1943376</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's what i did Sandra &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 18 May 2016 16:20:15 GMT</pubDate>
    <dc:creator>ricky_shaw</dc:creator>
    <dc:date>2016-05-18T16:20:15Z</dc:date>
    <item>
      <title>Mutiple Counter variables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/mutiple-counter-variables/m-p/11648427#M1943365</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Experts, I have an internal table holding various types of product. The number of entries in this internal table can vary. There can be 100 entries with 3,4,5 product types or even more different product types can be appended. Depending upon the type of product, I need to increment a counter variable(type i) and show the count on the report. If the number of product types is fixed, i can use a fixed no of counter variables. But in this case how many counter variables can i use? How can i do this? Pls suggest.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 May 2016 16:56:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/mutiple-counter-variables/m-p/11648427#M1943365</guid>
      <dc:creator>ricky_shaw</dc:creator>
      <dc:date>2016-05-17T16:56:41Z</dc:date>
    </item>
    <item>
      <title>Re: Mutiple Counter variables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/mutiple-counter-variables/m-p/11648428#M1943366</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You may count using an internal table and COLLECT statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 May 2016 17:12:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/mutiple-counter-variables/m-p/11648428#M1943366</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2016-05-17T17:12:34Z</dc:date>
    </item>
    <item>
      <title>Re: Mutiple Counter variables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/mutiple-counter-variables/m-p/11648429#M1943367</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ricky,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use &lt;SPAN style="font-size: 13.3333px;"&gt;SELECT COUNT statement to count each relevant field according to your criteria.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can read more here: &lt;A href="http://help.sap.com/abapdocu_702/en/abapselect_aggregate.htm" title="http://help.sap.com/abapdocu_702/en/abapselect_aggregate.htm"&gt;ABAP Keyword Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example, to determine the number of airlines flying to New York, you can do the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
&lt;P&gt;DATA count TYPE i. &lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;SELECT COUNT( DISTINCT carrid ) &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM spfli &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INTO count &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WHERE cityto = 'NEW YORK'. &lt;/P&gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Felipe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 May 2016 17:45:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/mutiple-counter-variables/m-p/11648429#M1943367</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2016-05-17T17:45:24Z</dc:date>
    </item>
    <item>
      <title>Re: Mutiple Counter variables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/mutiple-counter-variables/m-p/11648430#M1943368</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Felipe,&lt;/P&gt;&lt;P&gt;This is something to count from internal table entries. &lt;/P&gt;&lt;P&gt;So select Count** will not work here.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 May 2016 18:09:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/mutiple-counter-variables/m-p/11648430#M1943368</guid>
      <dc:creator>ricky_shaw</dc:creator>
      <dc:date>2016-05-17T18:09:54Z</dc:date>
    </item>
    <item>
      <title>Re: Mutiple Counter variables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/mutiple-counter-variables/m-p/11648431#M1943369</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ricky,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this case, you could create a copy of the original internal table and then delete all entries that do not match your criteria. Then, you just count the number of lines in it.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
&lt;P&gt;* copy contents from one itab to another of same type&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; copy_itab[] = &lt;SPAN style="font-size: 13.3333px;"&gt;original_itab&lt;/SPAN&gt;[].&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DELETE &lt;SPAN style="font-size: 13.3333px;"&gt;copy_itab&lt;/SPAN&gt; WHERE NOT product_type = 'type1'.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;* count lines of itab copy&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; quantity = LINES( &lt;SPAN style="font-size: 13.3333px;"&gt;copy_itab&lt;/SPAN&gt; ).&lt;/P&gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Felipe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 May 2016 18:16:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/mutiple-counter-variables/m-p/11648431#M1943369</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2016-05-17T18:16:37Z</dc:date>
    </item>
    <item>
      <title>Re: Mutiple Counter variables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/mutiple-counter-variables/m-p/11648432#M1943370</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Ricky,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Declare another internal table as like original internal table,move the original internal table data into declared internal table, and then sort internal table based on product type and delete adjacent duplicates based on product type.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background-position: initial;"&gt;* copy contents from one itab to another of same type&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background-position: initial;"&gt;&amp;nbsp; itab[] = &lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 13.3333px; font-family: inherit; background-position: initial;"&gt;original_itab&lt;/SPAN&gt;[].&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333; background-position: initial;"&gt;&amp;nbsp; &lt;SPAN class="L0S52"&gt;SORT &lt;/SPAN&gt;itab &lt;SPAN style="color: #333333; font-size: 12px;"&gt;by product_type.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN class="L0S52"&gt;DELETE &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;ADJACENT &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;DUPLICATES &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;FROM &lt;/SPAN&gt;itab &lt;SPAN class="L0S52"&gt;COMPARING &lt;SPAN style="color: #333333; font-size: 12px;"&gt;product_type.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN class="L0S52"&gt;DESCRIBE &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;TABLE &lt;/SPAN&gt;itab &lt;SPAN class="L0S52"&gt;LINES &lt;/SPAN&gt;lv_count&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S55"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Thanks,Sateesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 May 2016 20:08:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/mutiple-counter-variables/m-p/11648432#M1943370</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2016-05-17T20:08:08Z</dc:date>
    </item>
    <item>
      <title>Re: Mutiple Counter variables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/mutiple-counter-variables/m-p/11648433#M1943371</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh! &lt;/P&gt;&lt;P&gt;I want to count the number of product types. I don't want to eliminate the duplicates.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 May 2016 20:42:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/mutiple-counter-variables/m-p/11648433#M1943371</guid>
      <dc:creator>ricky_shaw</dc:creator>
      <dc:date>2016-05-17T20:42:31Z</dc:date>
    </item>
    <item>
      <title>Re: Mutiple Counter variables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/mutiple-counter-variables/m-p/11648434#M1943372</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-size: 13.3333px;"&gt;Ricky,&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;If you perform the deletions, as per my previous reply or via &lt;SPAN style="color: #333333; font-size: 12px;"&gt;Sateesh's method, it will achieve the same.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;You will have a copy of the original table with only the records that match your criteria, therefore, by counting its lines, you should get the count of each product type.&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;Regards,&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;Felipe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 May 2016 20:46:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/mutiple-counter-variables/m-p/11648434#M1943372</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2016-05-17T20:46:06Z</dc:date>
    </item>
    <item>
      <title>Re: Mutiple Counter variables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/mutiple-counter-variables/m-p/11648435#M1943373</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Felipe,&lt;/P&gt;&lt;P&gt;I am sorry for the confusion.&lt;/P&gt;&lt;P&gt;I need to display the no of times each product type is found and display its count.&lt;/P&gt;&lt;P&gt;I want to increase the counter for every product type even if it repeated.&lt;/P&gt;&lt;P&gt;My concern is how many variables do i need (to count) for every different product type?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So i need to use the internal table with collect statement a suggested by Sandra.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 May 2016 22:17:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/mutiple-counter-variables/m-p/11648435#M1943373</guid>
      <dc:creator>ricky_shaw</dc:creator>
      <dc:date>2016-05-17T22:17:47Z</dc:date>
    </item>
    <item>
      <title>Re: Mutiple Counter variables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/mutiple-counter-variables/m-p/11648436#M1943374</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Try this one.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Sort the table by product type.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;make use of index checking the current/previous product type&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data: &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; l_ctr TYPE i,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Counter for # of product type&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; l_index TYPE sy-tabix.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;l_index = 1.&lt;/P&gt;&lt;P&gt;l_ctr = 1.&lt;/P&gt;&lt;P&gt;Sort table BY product type.&lt;/P&gt;&lt;P&gt;LOOP at i_table INTO current.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ADD 1 to l_index.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Read table i_table INTO next INDEX l_index.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Check if next entry equal to previous record product type&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF current-product_type NE next-product_type.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ADD 1 to l_ctr.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ENDIF.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 May 2016 01:35:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/mutiple-counter-variables/m-p/11648436#M1943374</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2016-05-18T01:35:55Z</dc:date>
    </item>
    <item>
      <title>Re: Mutiple Counter variables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/mutiple-counter-variables/m-p/11648437#M1943375</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You'll get explanations and examples in the ABAP documentation for COLLECT statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In short :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Structure and Internal table with 2 components: product type and counter of type I for instance. By default, the key will be product type.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For every line of the main internal table, you fill the structure with the product type and counter equal to value 1, and you use COLLECT to fill the internal table. After the loop, you'll have one line per product type, and the counter will be the number of lines per product type.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 May 2016 05:54:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/mutiple-counter-variables/m-p/11648437#M1943375</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2016-05-18T05:54:48Z</dc:date>
    </item>
    <item>
      <title>Re: Mutiple Counter variables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/mutiple-counter-variables/m-p/11648438#M1943376</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's what i did Sandra &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 May 2016 16:20:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/mutiple-counter-variables/m-p/11648438#M1943376</guid>
      <dc:creator>ricky_shaw</dc:creator>
      <dc:date>2016-05-18T16:20:15Z</dc:date>
    </item>
  </channel>
</rss>

