<?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: adding amounts in an internal table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/adding-amounts-in-an-internal-table/m-p/3670262#M884025</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt; One way of doing this is by Collect statement as mentioned in previous post.&lt;/P&gt;&lt;P&gt;Other way is &lt;/P&gt;&lt;P&gt;Suppose itab is your internal table with BP no and amount.&lt;/P&gt;&lt;P&gt;Do like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;make another internal table of same type itab1.&lt;/P&gt;&lt;P&gt;sort itab by BP no.&lt;/P&gt;&lt;P&gt;data : l_bp type bu_partner.&lt;/P&gt;&lt;P&gt;read table itab index 1.&lt;/P&gt;&lt;P&gt;l_bp = itab-partner.&lt;/P&gt;&lt;P&gt;loop at itab.&lt;/P&gt;&lt;P&gt;if itab-partner eq l_bp.&lt;/P&gt;&lt;P&gt;sum = itab-amount.&lt;/P&gt;&lt;P&gt;itab1-sum = sum + itab-sum.&lt;/P&gt;&lt;P&gt;itab1-partner = itab-partner&lt;/P&gt;&lt;P&gt;else.&lt;/P&gt;&lt;P&gt;append itab1.&lt;/P&gt;&lt;P&gt;l_bp = itab-partner.&lt;/P&gt;&lt;P&gt;sum = itab-amount.&lt;/P&gt;&lt;P&gt;itab1-sum = sum + itab-sum.&lt;/P&gt;&lt;P&gt;itab1-partner = itab-partner.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;append itab1&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;Sourabh.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 08 Apr 2008 09:37:00 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-04-08T09:37:00Z</dc:date>
    <item>
      <title>adding amounts in an internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/adding-amounts-in-an-internal-table/m-p/3670258#M884021</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have created an internal table which has values BP number, Contract Account and amount paid. i would like to add the amounts paid per business partner and per contract account and only display the total amount paid per business partner and per contract account. may i have the code to make the addition of the amounts in an internal table.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Apr 2008 09:08:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/adding-amounts-in-an-internal-table/m-p/3670258#M884021</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-08T09:08:38Z</dc:date>
    </item>
    <item>
      <title>Re: adding amounts in an internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/adding-amounts-in-an-internal-table/m-p/3670259#M884022</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;instead of append use collect-statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards, dieter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Apr 2008 09:11:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/adding-amounts-in-an-internal-table/m-p/3670259#M884022</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-08T09:11:45Z</dc:date>
    </item>
    <item>
      <title>Re: adding amounts in an internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/adding-amounts-in-an-internal-table/m-p/3670260#M884023</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi...&lt;/P&gt;&lt;P&gt;at first wat u must do is make sure dat ur int table structure has the BP no 1st ,den the contract no and last the amt paid.&lt;/P&gt;&lt;P&gt;if the struc is not lik dis the following code wont work.&lt;/P&gt;&lt;P&gt;and also declare another int table with de same structure as de previous one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;code-&lt;/P&gt;&lt;P&gt;1st sort the int table by BP no and contract no in ascending order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at ITAB.&lt;/P&gt;&lt;P&gt;move ITAB to ITAB1.&lt;/P&gt;&lt;P&gt;at end contractno.&lt;/P&gt;&lt;P&gt;sum.&lt;/P&gt;&lt;P&gt;ITAB1-contractno = ITAB-contractno.&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;now ur ITAB1 will contain wat u require.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;reward points if useful.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Regards&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Winnie&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Apr 2008 09:18:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/adding-amounts-in-an-internal-table/m-p/3670260#M884023</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-08T09:18:58Z</dc:date>
    </item>
    <item>
      <title>Re: adding amounts in an internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/adding-amounts-in-an-internal-table/m-p/3670261#M884024</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;So what was meant is that for the same business partners and same Contract account numbers the amount should get added.....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do the following...imagine that you have data in int_tab with 3 fields...Declare int_tab1 as the same internal table type&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sort int_tab by BP Contract_AC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at int_tab into workarea.&lt;/P&gt;&lt;P&gt;collect workarea to int_tab1.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Collect statement compares the "BP" and "Contract A/C"&lt;/P&gt;&lt;P&gt;and for the same BP and contractA/C number it adds and appends..if an entry exists in int_tab1 it adds the amount only&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;eg:&lt;/P&gt;&lt;P&gt;BP | CAno: | Amount&lt;/P&gt;&lt;P&gt;A   |  23A      | 100&lt;/P&gt;&lt;P&gt;A   |  23A      | 50&lt;/P&gt;&lt;P&gt;A   |  24A      |  11&lt;/P&gt;&lt;P&gt;B   |  23A      | 12&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;after the collect statement..internal table contains&lt;/P&gt;&lt;P&gt;A | 23A | 150&lt;/P&gt;&lt;P&gt;A | 24A | 11&lt;/P&gt;&lt;P&gt;B | 23A | 12&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but it will work only if int_tab contais 3 fields as mentioned..if more fields are there which are non-numeric it will compare that also...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;in addition to it also check if the contract Account number is getting added by putting a breakpoint in the code&lt;/STRONG&gt;..if so... there are 2 options&lt;/P&gt;&lt;P&gt;(1) Declare a new internal table and pass the field contract number as a character....and use collect on the new internal table..so the contract account number will not get added...&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;instead of collect statement use loops and other logic to suit your requirement&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward if helpful&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Byju&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Apr 2008 09:31:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/adding-amounts-in-an-internal-table/m-p/3670261#M884024</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-08T09:31:47Z</dc:date>
    </item>
    <item>
      <title>Re: adding amounts in an internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/adding-amounts-in-an-internal-table/m-p/3670262#M884025</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt; One way of doing this is by Collect statement as mentioned in previous post.&lt;/P&gt;&lt;P&gt;Other way is &lt;/P&gt;&lt;P&gt;Suppose itab is your internal table with BP no and amount.&lt;/P&gt;&lt;P&gt;Do like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;make another internal table of same type itab1.&lt;/P&gt;&lt;P&gt;sort itab by BP no.&lt;/P&gt;&lt;P&gt;data : l_bp type bu_partner.&lt;/P&gt;&lt;P&gt;read table itab index 1.&lt;/P&gt;&lt;P&gt;l_bp = itab-partner.&lt;/P&gt;&lt;P&gt;loop at itab.&lt;/P&gt;&lt;P&gt;if itab-partner eq l_bp.&lt;/P&gt;&lt;P&gt;sum = itab-amount.&lt;/P&gt;&lt;P&gt;itab1-sum = sum + itab-sum.&lt;/P&gt;&lt;P&gt;itab1-partner = itab-partner&lt;/P&gt;&lt;P&gt;else.&lt;/P&gt;&lt;P&gt;append itab1.&lt;/P&gt;&lt;P&gt;l_bp = itab-partner.&lt;/P&gt;&lt;P&gt;sum = itab-amount.&lt;/P&gt;&lt;P&gt;itab1-sum = sum + itab-sum.&lt;/P&gt;&lt;P&gt;itab1-partner = itab-partner.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;append itab1&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;Sourabh.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Apr 2008 09:37:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/adding-amounts-in-an-internal-table/m-p/3670262#M884025</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-08T09:37:00Z</dc:date>
    </item>
  </channel>
</rss>

