<?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: Sum not working for table fields in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sum-not-working-for-table-fields/m-p/6417131#M1408687</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;Yes, this would probably work. &lt;/P&gt;&lt;P&gt;However, is there any reason why my original code is not working?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 09 Dec 2009 21:19:27 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-12-09T21:19:27Z</dc:date>
    <item>
      <title>Sum not working for table fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sum-not-working-for-table-fields/m-p/6417128#M1408684</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;I have an internal table that contains over 10 fields.&lt;/P&gt;&lt;P&gt;One of those fields is the activity type. I have several activity types, sorted descending.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Each record with an activity type also contains a field with a currency.&lt;/P&gt;&lt;P&gt;As such, for all unique activity types in my table, I am trying to sum the currency.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, the following code isn't working. No sum is being created for unique the unique combination of activity types: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  SORT I_COST1 BY LSTAR DESCENDING.

I_COST2[] = I_COST1[].
  LOOP AT I_COST2.

    AT END OF LSTAR.

      SUM.

    ENDAT.

  ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What am I doing wrong. Please help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Dec 2009 20:44:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sum-not-working-for-table-fields/m-p/6417128#M1408684</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-12-09T20:44:31Z</dc:date>
    </item>
    <item>
      <title>Re: Sum not working for table fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sum-not-working-for-table-fields/m-p/6417129#M1408685</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;Try doing something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT I_COST1 BY LSTAR DESCENDING.&lt;/P&gt;&lt;P&gt;I_COST2[] = I_COST1[].&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT  I_COST2.&lt;/P&gt;&lt;P&gt;   LOOP AT  I_COST1 WHERE  I_COST1-LSTAR =  I_COST2-LSTAR.&lt;/P&gt;&lt;P&gt;        LS_ I_COST1-CURRENCY =  LS_I_COST1-CURRENCY +  I_COST1-CURRENCY.&lt;/P&gt;&lt;P&gt;   ENDLOOP.    &lt;/P&gt;&lt;P&gt;  MODIFY  I_COST1  FROM LS_I_COST1 TRANSPORTING CURRENCY WHERE LSTAR = I_COST2-LSTAR.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;P{lease let me know if you still have any issue?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Karuna.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Dec 2009 21:15:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sum-not-working-for-table-fields/m-p/6417129#M1408685</guid>
      <dc:creator>karuna_gangireddy</dc:creator>
      <dc:date>2009-12-09T21:15:06Z</dc:date>
    </item>
    <item>
      <title>Re: Sum not working for table fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sum-not-working-for-table-fields/m-p/6417130#M1408686</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Post your internal table definition.  Did you exclude some code from the post or are you just looking at the results in debug mode?  I'm not sure whether you're referring to a non-unique sum because your table isn't set up correctly, or because the field isn't typed correctly, or because there's no handling code after the 'SUM'?  Most likely you're expecting something to happen with that SUM command other than just putting the SUM'd value in the work area...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Dec 2009 21:18:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sum-not-working-for-table-fields/m-p/6417130#M1408686</guid>
      <dc:creator>brad_bohn</dc:creator>
      <dc:date>2009-12-09T21:18:07Z</dc:date>
    </item>
    <item>
      <title>Re: Sum not working for table fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sum-not-working-for-table-fields/m-p/6417131#M1408687</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;Yes, this would probably work. &lt;/P&gt;&lt;P&gt;However, is there any reason why my original code is not working?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Dec 2009 21:19:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sum-not-working-for-table-fields/m-p/6417131#M1408687</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-12-09T21:19:27Z</dc:date>
    </item>
    <item>
      <title>Re: Sum not working for table fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sum-not-working-for-table-fields/m-p/6417132#M1408688</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The following is the table definition:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
TYPES: BEGIN OF S_COST1,
  SPTAG TYPE S227-SPTAG,
  WERKS TYPE S227-WERKS,
  MATNR TYPE S227-MATNR,
  MAKTX TYPE MAKT-MAKTX,
  MCOMP TYPE S227-MCOMP,
  LSTAR TYPE S227-LSTAR,
  KTEXT TYPE CSLT-KTEXT,
  VERID TYPE S227-VERID,
  HWAER TYPE S227-HWAER,
  WERTN TYPE S227-WERTN,
  AMEIN TYPE S225-AMEIN,
  WAMNG TYPE S225-WEMNG,
  AUFNR TYPE AUFK-AUFNR,
  AUART TYPE AUFK-AUART,
  LOEKZ TYPE CKMLMV013-LOEKZ,
  VNPRD_EA TYPE CKMLCR-VNPRD_EA,
  VNPRD_MA TYPE CKMLCR-VNPRD_MA,
  ML_COST TYPE CK_VNPRDEA.
TYPES: END OF S_COST1.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the only relative code for this question. I am expecting to receive a sum.&lt;/P&gt;&lt;P&gt;There is no handling code after this relating to sum. However, via tutorials, I have found that there doesn't have to be.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Dec 2009 21:21:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sum-not-working-for-table-fields/m-p/6417132#M1408688</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-12-09T21:21:44Z</dc:date>
    </item>
    <item>
      <title>Re: Sum not working for table fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sum-not-working-for-table-fields/m-p/6417133#M1408689</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You should check the help for SUM and AT END. Basically, for this to work, LSTAR has to be the first field of the internal table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Dec 2009 21:27:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sum-not-working-for-table-fields/m-p/6417133#M1408689</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-12-09T21:27:15Z</dc:date>
    </item>
    <item>
      <title>Re: Sum not working for table fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sum-not-working-for-table-fields/m-p/6417134#M1408690</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So, your AT is going to trigger too many times for the same LSTAR and you won't receive a unique sum.  You'll receive a sum based on any of the fields changing to the left of LSTAR.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Dec 2009 21:28:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sum-not-working-for-table-fields/m-p/6417134#M1408690</guid>
      <dc:creator>brad_bohn</dc:creator>
      <dc:date>2009-12-09T21:28:23Z</dc:date>
    </item>
    <item>
      <title>Re: Sum not working for table fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sum-not-working-for-table-fields/m-p/6417135#M1408691</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've just put it as the 1st field. However, it's still not working. Frustrating, since I've used sum before.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Dec 2009 21:29:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sum-not-working-for-table-fields/m-p/6417135#M1408691</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-12-09T21:29:11Z</dc:date>
    </item>
    <item>
      <title>Re: Sum not working for table fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sum-not-working-for-table-fields/m-p/6417136#M1408692</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What isn't working though?  Do you mean the value isn't correct in the work area or that you're expecting the table to retain the SUM somehow?  You need to 'do something' (write it out, store it in another table, etc.) with the sum in order to retain it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Dec 2009 21:46:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sum-not-working-for-table-fields/m-p/6417136#M1408692</guid>
      <dc:creator>brad_bohn</dc:creator>
      <dc:date>2009-12-09T21:46:58Z</dc:date>
    </item>
    <item>
      <title>Re: Sum not working for table fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sum-not-working-for-table-fields/m-p/6417137#M1408693</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I just built a small program to test this.&lt;/P&gt;&lt;P&gt;Along with your reply, I just had one of those "oy" moments, where you realize just how stupid you are.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the replies everyone..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Dec 2009 21:51:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sum-not-working-for-table-fields/m-p/6417137#M1408693</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-12-09T21:51:43Z</dc:date>
    </item>
  </channel>
</rss>

