<?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: collect it_ in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/collect-it/m-p/5359435#M1233729</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;COLLECT statement SUMs the Numerical fields while comparing all the char fileds. so in your case you want to have count of Bukrs. To achevie this you need to have one more column for count initially this column holds the value in the internal table. When you loop this internal table and collect the data in other internal table then count field get's summed up for all common bukrs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the other  way..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SORT ITAB BY BUKRS.
LOOP AT itab.
CNT = CNT + 1.

AT END OF BUKRS.
  ITAB1-BUKRS = ITAB-BUKRS.
  ITAB1-CNT = CNT.
  APPEND ITAB1.
  CLEAR : ITAB1, CNT.
ENDAT.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 03 Apr 2009 13:48:53 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-04-03T13:48:53Z</dc:date>
    <item>
      <title>collect it_</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/collect-it/m-p/5359431#M1233725</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all, &lt;/P&gt;&lt;P&gt;I have internal table with bukrs numbers , how to create second table which will contain number of bukrs. &lt;/P&gt;&lt;P&gt;EG. I have  bukrs 1020 &lt;/P&gt;&lt;P&gt;                          1020 &lt;/P&gt;&lt;P&gt;                          1008 &lt;/P&gt;&lt;P&gt;                          1008 &lt;/P&gt;&lt;P&gt;                          1008 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tale must contain  1020     &lt;STRONG&gt;2&lt;/STRONG&gt; rec &lt;/P&gt;&lt;P&gt;                           1008     &lt;STRONG&gt;3&lt;/STRONG&gt; rec&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Apr 2009 13:35:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/collect-it/m-p/5359431#M1233725</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-03T13:35:21Z</dc:date>
    </item>
    <item>
      <title>Re: collect it_</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/collect-it/m-p/5359432#M1233726</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Nick,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;create another internal table with fields put first field as Bukrs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;next sort the internal table with Bukrs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;next delete abjacent duplicates comapring Bukrs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

data : begin of itab occurs 0,
1
2
3
4
bukrs.
         end of itab.

data : begin of itab1,
Bukrs
         end of itab.

Loop at itab.
move-corresponding itab to itab1.
append itab1.
endloop.

sort itab1.
delete adjacent duplicates from itab1.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Prabhduas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Apr 2009 13:42:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/collect-it/m-p/5359432#M1233726</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-03T13:42:06Z</dc:date>
    </item>
    <item>
      <title>Re: collect it_</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/collect-it/m-p/5359433#M1233727</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use COLLECT statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For it create second field qty of type Integer. First put 1 to every record of it-qty.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then collect them.&lt;/P&gt;&lt;P&gt;Type of  t_serno1-qty  is Integer .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT t_tserno INTO w_tserno_ds.&lt;/P&gt;&lt;P&gt;        w_tserno1_ds-fld1 = w_tserno_ds-fld1.&lt;/P&gt;&lt;P&gt;        w_tserno1_ds-qty = 1.&lt;/P&gt;&lt;P&gt;        COLLECT w_tserno1_ds INTO t_tserno1.&lt;/P&gt;&lt;P&gt;        CLEAR : w_tserno1_ds.&lt;/P&gt;&lt;P&gt;ENDLOOP. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Amurta&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Apr 2009 13:43:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/collect-it/m-p/5359433#M1233727</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-03T13:43:39Z</dc:date>
    </item>
    <item>
      <title>Re: collect it_</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/collect-it/m-p/5359434#M1233728</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;build a table itab2 with two fields : BUKRS and NUM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;pass value 1 to the NUM field&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;loop at itab.
itab1-bukrs = itab-bukrs.
itab1-num = 1.
append itab1.
endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;your ITAB2 looks like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1020  1&lt;/P&gt;&lt;P&gt;1020  1&lt;/P&gt;&lt;P&gt;1008  1&lt;/P&gt;&lt;P&gt;1008  1&lt;/P&gt;&lt;P&gt;1008  1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then have another itab like itab2 (Call it itab3)&lt;/P&gt;&lt;P&gt;do like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;loop at itab2.
collect itab2 into itab3.
endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ravi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Apr 2009 13:48:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/collect-it/m-p/5359434#M1233728</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-03T13:48:16Z</dc:date>
    </item>
    <item>
      <title>Re: collect it_</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/collect-it/m-p/5359435#M1233729</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;COLLECT statement SUMs the Numerical fields while comparing all the char fileds. so in your case you want to have count of Bukrs. To achevie this you need to have one more column for count initially this column holds the value in the internal table. When you loop this internal table and collect the data in other internal table then count field get's summed up for all common bukrs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the other  way..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SORT ITAB BY BUKRS.
LOOP AT itab.
CNT = CNT + 1.

AT END OF BUKRS.
  ITAB1-BUKRS = ITAB-BUKRS.
  ITAB1-CNT = CNT.
  APPEND ITAB1.
  CLEAR : ITAB1, CNT.
ENDAT.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Apr 2009 13:48:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/collect-it/m-p/5359435#M1233729</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-03T13:48:53Z</dc:date>
    </item>
  </channel>
</rss>

