<?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: Summing value in Internal Table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/summing-value-in-internal-table/m-p/6515656#M1424291</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Rahul ,&lt;/P&gt;&lt;P&gt;Solution 1 :-Using own logic&lt;/P&gt;&lt;P&gt;Just use an on change of at the PO field ....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On change of (PO field) , sum the quantity  and put it ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Solution 2:Using COLLECT statement &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think there is no need of on change ..you could use the COLLECT  keyword &lt;/P&gt;&lt;P&gt;Comradely,&lt;/P&gt;&lt;P&gt;K.Sibi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: sibi k  kanagaraj on Dec 22, 2009 2:20 PM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: sibi k  kanagaraj on Dec 22, 2009 2:22 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 22 Dec 2009 13:20:16 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-12-22T13:20:16Z</dc:date>
    <item>
      <title>Summing value in Internal Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/summing-value-in-internal-table/m-p/6515654#M1424289</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Abapers,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have some problem during manipulating the internal table:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The scenario is like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have one internal Table:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Material     Curr   PO Quantity   &lt;/P&gt;&lt;P&gt;A              EUR     10&lt;/P&gt;&lt;P&gt;A              EUR     15&lt;/P&gt;&lt;P&gt;A              GBP     20&lt;/P&gt;&lt;P&gt;A              GBP     10&lt;/P&gt;&lt;P&gt;B              USD     10&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I have to Sum the POQty and put this in other field Sum of Internal Table on the basis of grouping materail as well as Curr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For Material A and Curr EUR, i should get sum of PO Qty 25 and &lt;/P&gt;&lt;P&gt;for material A and Curr GBP, i shld get sum of PO Qty 30 and &lt;/P&gt;&lt;P&gt;For B - USD, i shld get 10 in Sum field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to do this in ABAP Code?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please solve my this issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rahul Sinha&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Dec 2009 13:15:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/summing-value-in-internal-table/m-p/6515654#M1424289</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-12-22T13:15:52Z</dc:date>
    </item>
    <item>
      <title>Re: Summing value in Internal Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/summing-value-in-internal-table/m-p/6515655#M1424290</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rahul,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is quite simple. We can use COLLECT and it will sum automatically.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Declare another internal table, eg. STAB&lt;/P&gt;&lt;P&gt;   with three fields only&lt;/P&gt;&lt;P&gt;Material &lt;/P&gt;&lt;P&gt;Curr&lt;/P&gt;&lt;P&gt; PO Quantity &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Not loop at your original internal table say ITAB, and write like this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

loop at itab.

move-corresponding itab to stab.

COLLECT STAB.

Endloop.


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I assume STAB and ITAB have same field names, hence i have written move-corresponding.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Based upon PO and CURR combination, (ie. DISTINCT combination  of alphanumeric fields in STAB),&lt;/P&gt;&lt;P&gt;collect will do the sum automatically.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;amit m.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Dec 2009 13:20:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/summing-value-in-internal-table/m-p/6515655#M1424290</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-12-22T13:20:10Z</dc:date>
    </item>
    <item>
      <title>Re: Summing value in Internal Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/summing-value-in-internal-table/m-p/6515656#M1424291</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Rahul ,&lt;/P&gt;&lt;P&gt;Solution 1 :-Using own logic&lt;/P&gt;&lt;P&gt;Just use an on change of at the PO field ....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On change of (PO field) , sum the quantity  and put it ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Solution 2:Using COLLECT statement &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think there is no need of on change ..you could use the COLLECT  keyword &lt;/P&gt;&lt;P&gt;Comradely,&lt;/P&gt;&lt;P&gt;K.Sibi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: sibi k  kanagaraj on Dec 22, 2009 2:20 PM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: sibi k  kanagaraj on Dec 22, 2009 2:22 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Dec 2009 13:20:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/summing-value-in-internal-table/m-p/6515656#M1424291</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-12-22T13:20:16Z</dc:date>
    </item>
    <item>
      <title>Re: Summing value in Internal Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/summing-value-in-internal-table/m-p/6515657#M1424292</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rahul,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  While Appending the data to internal table use COLLECT statement instead of APPEND..&lt;/P&gt;&lt;P&gt;COLLECT statement will add the quantity fields if the other fields are same ie, material and currency fields in your case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So for your case, internal table will have data when you use COLLECT statement &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A EUR 25&lt;/P&gt;&lt;P&gt;A GBP 30&lt;/P&gt;&lt;P&gt;B USD 10&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Dec 2009 13:24:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/summing-value-in-internal-table/m-p/6515657#M1424292</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-12-22T13:24:41Z</dc:date>
    </item>
    <item>
      <title>Re: Summing value in Internal Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/summing-value-in-internal-table/m-p/6515658#M1424293</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please do not ask or answer basic questions - thread locked.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Dec 2009 18:15:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/summing-value-in-internal-table/m-p/6515658#M1424293</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-12-22T18:15:30Z</dc:date>
    </item>
  </channel>
</rss>

