<?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 Issue With Dynamic Internal Table Calculations in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/issue-with-dynamic-internal-table-calculations/m-p/7696189#M1577515</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;&lt;/P&gt;&lt;P&gt;I have a dynamic internal Table   and i want to calculate the sum of QTY if MAT is same&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Say ITAB is my dynamic internal table With below entries&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;MAT             QTY

    A            1
    A            2
    A            3
    B            4
    B            5
    C            6&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want my dynamic internal table to look like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;A    6
B    9
C    6&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) I tried below code &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT &amp;lt;itab&amp;gt; INTO &amp;lt;WA&amp;gt;.
  assign &amp;lt;WA&amp;gt; TO &amp;lt;WA_TEMP&amp;gt;.
    assign component 'MAT' of structure &amp;lt;wa&amp;gt; to &amp;lt;fs&amp;gt;.

  at end of &amp;lt;fs&amp;gt;.
   SUM.  *" SUM Not allowed with in loop assigning*
   ENDAT.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Would appreciate if anyone can comment on the issue&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 17 Feb 2011 23:19:51 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-02-17T23:19:51Z</dc:date>
    <item>
      <title>Issue With Dynamic Internal Table Calculations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/issue-with-dynamic-internal-table-calculations/m-p/7696189#M1577515</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;&lt;/P&gt;&lt;P&gt;I have a dynamic internal Table   and i want to calculate the sum of QTY if MAT is same&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Say ITAB is my dynamic internal table With below entries&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;MAT             QTY

    A            1
    A            2
    A            3
    B            4
    B            5
    C            6&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want my dynamic internal table to look like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;A    6
B    9
C    6&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) I tried below code &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT &amp;lt;itab&amp;gt; INTO &amp;lt;WA&amp;gt;.
  assign &amp;lt;WA&amp;gt; TO &amp;lt;WA_TEMP&amp;gt;.
    assign component 'MAT' of structure &amp;lt;wa&amp;gt; to &amp;lt;fs&amp;gt;.

  at end of &amp;lt;fs&amp;gt;.
   SUM.  *" SUM Not allowed with in loop assigning*
   ENDAT.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Would appreciate if anyone can comment on the issue&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Feb 2011 23:19:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/issue-with-dynamic-internal-table-calculations/m-p/7696189#M1577515</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-02-17T23:19:51Z</dc:date>
    </item>
    <item>
      <title>Re: Issue With Dynamic Internal Table Calculations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/issue-with-dynamic-internal-table-calculations/m-p/7696190#M1577516</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello David,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would try to use COLLECT within the loop of itab instead of SUM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Sougata.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Feb 2011 23:48:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/issue-with-dynamic-internal-table-calculations/m-p/7696190#M1577516</guid>
      <dc:creator>Sougata</dc:creator>
      <dc:date>2011-02-17T23:48:48Z</dc:date>
    </item>
  </channel>
</rss>

