<?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: ERROR WHEN USING SUM in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-when-using-sum/m-p/12047577#M1968464</link>
    <description>&lt;P&gt;Hi &lt;/P&gt;&lt;P&gt;I will like to sum rows rows that have the specific cost centre and get their sum and input into dhu1.&lt;/P&gt;&lt;P&gt;eg: sum values for costcentre 1380 and input into a field called 1380 then sum values for cost centre 1340 input the total value into cost centre 1340.&lt;/P&gt;</description>
    <pubDate>Tue, 19 Nov 2019 14:01:57 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2019-11-19T14:01:57Z</dc:date>
    <item>
      <title>ERROR WHEN USING SUM</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-when-using-sum/m-p/12047575#M1968462</link>
      <description>&lt;P&gt;Hi all&lt;/P&gt;
  &lt;P&gt;I am trying to sum up field-WERTN when the condition is equal to '1380' and to input the sum value into field DHU1.please can you help me to correct the error below.&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1744865-abap11.jpg" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2019 13:14:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-when-using-sum/m-p/12047575#M1968462</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-11-19T13:14:50Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR WHEN USING SUM</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-when-using-sum/m-p/12047576#M1968463</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Your code and logic doesn't look good. Can you be a liitle more precise what are you trying to achieve? Do you want to write only the rows that have the specific cost centre and get their sum or do you want to write all the rows and get the current total into the field DHU1 for specific cost centre?&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Igor&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2019 13:40:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-when-using-sum/m-p/12047576#M1968463</guid>
      <dc:creator>IN</dc:creator>
      <dc:date>2019-11-19T13:40:47Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR WHEN USING SUM</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-when-using-sum/m-p/12047577#M1968464</link>
      <description>&lt;P&gt;Hi &lt;/P&gt;&lt;P&gt;I will like to sum rows rows that have the specific cost centre and get their sum and input into dhu1.&lt;/P&gt;&lt;P&gt;eg: sum values for costcentre 1380 and input into a field called 1380 then sum values for cost centre 1340 input the total value into cost centre 1340.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2019 14:01:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-when-using-sum/m-p/12047577#M1968464</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-11-19T14:01:57Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR WHEN USING SUM</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-when-using-sum/m-p/12047578#M1968465</link>
      <description>&lt;P&gt;&lt;A href="https://answers.sap.com/users/57865/zubair1710.html"&gt;zubair sultan&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;You can do this in a single query, you don't need to write loop. &lt;/P&gt;&lt;P&gt;Below code for example, &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT    werks,  datum, uzeit, extnb, deprt, dpext, SUM( amunt ) AS amunt
  INTO      CORRESPONDING FIELDS OF TABLE @gt_compr
  FROM      yrt_h_sales
  WHERE     werks IN @so_werks
  AND       datum IN @so_datum
  GROUP BY  werks, datum, uzeit,  extnb, deprt, dpext.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Just refer the above code and modify yours.&lt;/P&gt;&lt;P&gt;Regards &lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2019 14:11:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-when-using-sum/m-p/12047578#M1968465</guid>
      <dc:creator>former_member1716</dc:creator>
      <dc:date>2019-11-19T14:11:49Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR WHEN USING SUM</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-when-using-sum/m-p/12047579#M1968466</link>
      <description>&lt;P&gt;&lt;A href="https://answers.sap.com/users/57865/zubair1710.html"&gt;zubair sultan&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;Can you let us know your select query based on that we can suggest. &lt;/P&gt;&lt;P&gt;Regards &lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2019 14:14:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-when-using-sum/m-p/12047579#M1968466</guid>
      <dc:creator>former_member1716</dc:creator>
      <dc:date>2019-11-19T14:14:05Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR WHEN USING SUM</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-when-using-sum/m-p/12047580#M1968467</link>
      <description>&lt;P&gt;There are different ways of achieving the goal, dependant of your needs.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;The recommendation of  &lt;SPAN class="mention-scrubbed"&gt;satishkumarbalasubramanian&lt;/SPAN&gt; &lt;/LI&gt;&lt;LI&gt;Through the loop statement by keeping the sum into the local internal table with totals for the cost centre and fetching the end result in the end or after every row.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Igor&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2019 14:22:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-when-using-sum/m-p/12047580#M1968467</guid>
      <dc:creator>IN</dc:creator>
      <dc:date>2019-11-19T14:22:57Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR WHEN USING SUM</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-when-using-sum/m-p/12047581#M1968468</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;
SPAN {
font-family: "Courier New";
font-size: 10pt;
color: #000000;
background: #FFFFFF;
}
.L0S33 {
color: #4DA619;
}
.L0S52 {
color: #0000FF;
}
.L0S55 {
color: #800080;
}
.L0S70 {
color: #808080;
}

SELECT: A~MATNR A~BWKEY B~KST001 B~KST004 B~KST006 B~KST010 B~KALNR C~KSTAR C~WERTN C~LSTAR C~KOSTL

  FROM mbew AS a

  JOIN keph AS b

  ON a~kaln1 EQ b~kalnr INNER JOIN CKIS AS C

  ON B~KALNR EQ C~KALNR

  AND

   B~KADKY EQ C~KADKY

  INTO CORRESPONDING FIELDS OF TABLE it_keph

WHERE A~MATNR IN MATERIAL

    and a~bwkey EQ '3000'

    AND B~KKZST EQ 'X'

    AND B~KADKY IN COSTINGD.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Nov 2019 14:27:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-when-using-sum/m-p/12047581#M1968468</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-11-19T14:27:26Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR WHEN USING SUM</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-when-using-sum/m-p/12047582#M1968469</link>
      <description>&lt;P&gt;&lt;A href="https://answers.sap.com/users/57865/zubair1710.html"&gt;zubair sultan&lt;/A&gt;, &lt;/P&gt;&lt;P&gt;In this case you need to do use the control break statements concepts.&lt;/P&gt;&lt;P&gt;Refer to the below link to know more about control break statements. &lt;/P&gt;&lt;P&gt;&lt;A href="https://wiki.scn.sap.com/wiki/display/ABAP/Control+Level+Statements+in+ABAP" target="_blank"&gt;Control Break Statements &lt;/A&gt;&lt;/P&gt;&lt;P&gt;Thumb rule in using these statements, &lt;/P&gt;&lt;P&gt;All the fields before the required field on which the rule is applied must be equal only then your code will be effective. &lt;/P&gt;&lt;P&gt;In case you are only concerned about the cost centre then move the cost centre to first field in your internal table. &lt;/P&gt;&lt;P&gt;Regards!!! &lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2019 15:33:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-when-using-sum/m-p/12047582#M1968469</guid>
      <dc:creator>former_member1716</dc:creator>
      <dc:date>2019-11-19T15:33:07Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR WHEN USING SUM</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-when-using-sum/m-p/12047583#M1968470</link>
      <description>&lt;P&gt;There is no such the way to SUM like that inside LOOP. use control break as I already said in this &lt;A href="https://answers.sap.com/questions/12908699/how-to-sum-data-based-on-a-condition-into-a-new-fi.html?childToView=12910507#comment-12910507" target="_blank"&gt;comment&lt;/A&gt; . I just don't get why you only write out the specific cost center but select all of them.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2019 01:03:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-when-using-sum/m-p/12047583#M1968470</guid>
      <dc:creator>DoanManhQuynh</dc:creator>
      <dc:date>2019-11-20T01:03:12Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR WHEN USING SUM</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-when-using-sum/m-p/12047584#M1968471</link>
      <description>&lt;P&gt;I just selected one has a example I do need all cost centre.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2019 01:05:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-when-using-sum/m-p/12047584#M1968471</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-11-20T01:05:59Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR WHEN USING SUM</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-when-using-sum/m-p/12047585#M1968472</link>
      <description>&lt;P&gt;I do need all  cost centres .my logic  is sum up column  CKIS-WERTN based  on condition CKIS-KOSTL  which is  linked to  cost estimate  number CKIS-kalnr.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2019 01:16:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-when-using-sum/m-p/12047585#M1968472</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-11-20T01:16:14Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR WHEN USING SUM</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-when-using-sum/m-p/12047586#M1968473</link>
      <description>&lt;P&gt;&lt;A href="https://answers.sap.com/users/57865/zubair1710.html"&gt;zubair sultan &lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;U&gt;&lt;/U&gt;&lt;SUB&gt;&lt;/SUB&gt;&lt;SUP&gt;&lt;/SUP&gt;&lt;DEL&gt;&lt;/DEL&gt;what you want is what ALV subtotal do, use ALV you don't have to sum up then write, ALV do it for you:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;cl_salv_table=&amp;gt;factory(
  IMPORTING
    r_salv_table   = salv
  CHANGING
    t_table        = it_keph  ).
salv-&amp;gt;get_sorts( )-&amp;gt;add_sort(
                             EXPORTING
                               columnname         = 'KOSTL'
                               sequence           = if_salv_c_sort=&amp;gt;sort_up
                               subtotal           = if_salv_c_bool_sap=&amp;gt;true
                            ).
salv-&amp;gt;get_aggregations( )-&amp;gt;add_aggregation(
                              EXPORTING
                               columnname         = 'WERTN'
                               aggregation        = if_salv_c_aggregation=&amp;gt;total ).
salv-&amp;gt;get_aggregations( )-&amp;gt;set_aggregation_before_items( ).
salv-&amp;gt;display( ).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If you still want to stick with class WRITE statement, then use AT END KOSTL ( please move it to the top of structure instead last component ) to sum and write, press F1 help on that statement you will find SAP sample for it.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2019 07:20:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-when-using-sum/m-p/12047586#M1968473</guid>
      <dc:creator>DoanManhQuynh</dc:creator>
      <dc:date>2019-11-20T07:20:22Z</dc:date>
    </item>
  </channel>
</rss>

