<?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 sum statement in reports in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sum-statement-in-reports/m-p/1353704#M176885</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi &lt;/P&gt;&lt;P&gt;suppose if sum stmt is encounter it adds the all numeric fields  in reports but i wnt only one field is summed how to get this one.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 29 Apr 2006 10:07:04 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-04-29T10:07:04Z</dc:date>
    <item>
      <title>sum statement in reports</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sum-statement-in-reports/m-p/1353704#M176885</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi &lt;/P&gt;&lt;P&gt;suppose if sum stmt is encounter it adds the all numeric fields  in reports but i wnt only one field is summed how to get this one.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 29 Apr 2006 10:07:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sum-statement-in-reports/m-p/1353704#M176885</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-04-29T10:07:04Z</dc:date>
    </item>
    <item>
      <title>Re: sum statement in reports</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sum-statement-in-reports/m-p/1353705#M176886</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kiran,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; When you use SUM i think you need to specify a field or if its used in the internal table control statements then it only sums the target field or the field on which AT events is triggered.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Cheers&lt;/P&gt;&lt;P&gt; VJ&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 29 Apr 2006 10:11:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sum-statement-in-reports/m-p/1353705#M176886</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-04-29T10:11:29Z</dc:date>
    </item>
    <item>
      <title>Re: sum statement in reports</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sum-statement-in-reports/m-p/1353706#M176887</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data: begin of itab occurs 0.&lt;/P&gt;&lt;P&gt;   field1 type i,&lt;/P&gt;&lt;P&gt;   field2 type i,&lt;/P&gt;&lt;P&gt;   field3  type i,&lt;/P&gt;&lt;P&gt; end of itab.&lt;/P&gt;&lt;P&gt;data: sum type i.&lt;/P&gt;&lt;P&gt; sum = 0.&lt;/P&gt;&lt;P&gt;loop at itab.&lt;/P&gt;&lt;P&gt;sum  = sum + itab-field1.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;write : sum.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 29 Apr 2006 10:11:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sum-statement-in-reports/m-p/1353706#M176887</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-04-29T10:11:39Z</dc:date>
    </item>
    <item>
      <title>Re: sum statement in reports</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sum-statement-in-reports/m-p/1353707#M176888</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi could u explain briefly ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 29 Apr 2006 10:20:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sum-statement-in-reports/m-p/1353707#M176888</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-04-29T10:20:48Z</dc:date>
    </item>
    <item>
      <title>Re: sum statement in reports</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sum-statement-in-reports/m-p/1353708#M176889</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kiran,&lt;/P&gt;&lt;P&gt;Are u talking abt sum in select statement..&lt;/P&gt;&lt;P&gt;There u need to specify the fieldname..&lt;/P&gt;&lt;P&gt;example:&lt;/P&gt;&lt;P&gt;SELECT SINGLE SUM( seatsocc )&lt;/P&gt;&lt;P&gt;FROM sflight INTO sum&lt;/P&gt;&lt;P&gt;WHERE fldate LIKE '2002%'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In case of control statement,&lt;/P&gt;&lt;P&gt;only the field on which event is triggered are summed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Refer to this example,&lt;/P&gt;&lt;P&gt;Here only T2 is summed..&lt;/P&gt;&lt;P&gt;REPORT DEMO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: T1(4), T2 TYPE I.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FIELD-GROUPS: HEADER, TEST.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INSERT T2 T1 INTO HEADER.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;T1 ='AABB'. T2 = 1. EXTRACT TEST.&lt;/P&gt;&lt;P&gt;T1 ='BBCC'. T2 = 2. EXTRACT TEST.&lt;/P&gt;&lt;P&gt;T1 ='AAAA'. T2 = 2. EXTRACT TEST.&lt;/P&gt;&lt;P&gt;T1 ='AABB'. T2 = 1. EXTRACT TEST.&lt;/P&gt;&lt;P&gt;T1 ='BBBB'. T2 = 2. EXTRACT TEST.&lt;/P&gt;&lt;P&gt;T1 ='BBCC'. T2 = 2. EXTRACT TEST.&lt;/P&gt;&lt;P&gt;T1 ='AAAA'. T2 = 1. EXTRACT TEST.&lt;/P&gt;&lt;P&gt;T1 ='BBBB'. T2 = 1. EXTRACT TEST.&lt;/P&gt;&lt;P&gt;T1 ='AAAA'. T2 = 3. EXTRACT TEST.&lt;/P&gt;&lt;P&gt;T1 ='AABB'. T2 = 1. EXTRACT TEST.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT BY T1 T2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  WRITE: /20 T1, T2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  AT END OF T2.&lt;/P&gt;&lt;P&gt;    ULINE.&lt;/P&gt;&lt;P&gt;    WRITE: 'Sum:', 20 SUM(T2).&lt;/P&gt;&lt;P&gt;    ULINE.&lt;/P&gt;&lt;P&gt;  ENDAT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  AT END OF T1.&lt;/P&gt;&lt;P&gt;    WRITE: 'Different values:', (6) CNT(T1).&lt;/P&gt;&lt;P&gt;  ULINE.&lt;/P&gt;&lt;P&gt;  ENDAT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  AT LAST.&lt;/P&gt;&lt;P&gt;ULINE.&lt;/P&gt;&lt;P&gt;    WRITE: 'Sum:', 20 SUM(T2),&lt;/P&gt;&lt;P&gt;/ 'Different values:', (6) CNT(T1).&lt;/P&gt;&lt;P&gt;  ENDAT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Tanveer.&lt;/P&gt;&lt;P&gt;Please mark helpful answers&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Tanveer Shaikh&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 29 Apr 2006 19:51:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sum-statement-in-reports/m-p/1353708#M176889</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-04-29T19:51:18Z</dc:date>
    </item>
    <item>
      <title>Re: sum statement in reports</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sum-statement-in-reports/m-p/1353709#M176890</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey Kiran,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sum statement in report is basically used in  Control Break Processing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After you fill an internal table with data, you often need to write the data out. This output will frequently contain summary information(uch as totals) at the top or bottom of the report.There might also be interim situations (such as subtotals ) within the body of report.&lt;/P&gt;&lt;P&gt;To do this , you can read the data into an internal table and then, within loop at , use the following statements: &lt;/P&gt;&lt;P&gt;1. at first / endat&lt;/P&gt;&lt;P&gt;2.at last / endat&lt;/P&gt;&lt;P&gt;3.at new / endat&lt;/P&gt;&lt;P&gt;4.at end of / endat&lt;/P&gt;&lt;P&gt;5.sum&lt;/P&gt;&lt;P&gt;6.on change of / endon.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first statement of each of these pairs - except for Sum - controls when the code lies between them is executed.This type of control is called a control break.Their purpose is to ececute the code between them whenever  a specific condition in the data is detected during the processing of the loop. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;u&amp;gt;&amp;lt;b&amp;gt;Using the Sum statement :&amp;lt;/b&amp;gt;&amp;lt;/u&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;syntax : &lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;at first/last/new/end of.&lt;/P&gt;&lt;P&gt;   ....&lt;/P&gt;&lt;P&gt;   sum&lt;/P&gt;&lt;P&gt;   ....&lt;/P&gt;&lt;P&gt;   endat.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where : &lt;/P&gt;&lt;P&gt; &amp;lt;b&amp;gt;...&amp;lt;/b&amp;gt; represents any  number of lines of code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sum calculates a total for the current value of the control level that contains it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It finds all rows that have the same values within the control level field and all fields of the left of it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;It sums each numeric column to the right of the control level.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It places the totals in the corresponding fields of the work area.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Now can you explain your situation more specifically, then it would be better for me to code the logic accordingly.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Kunal.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 30 Apr 2006 02:53:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sum-statement-in-reports/m-p/1353709#M176890</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-04-30T02:53:05Z</dc:date>
    </item>
    <item>
      <title>Re: sum statement in reports</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sum-statement-in-reports/m-p/1353710#M176891</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi whenever sum stmt is there it sums all the numeric fields in itab but iwant sum a particular field in control events&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 30 Apr 2006 08:03:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sum-statement-in-reports/m-p/1353710#M176891</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-04-30T08:03:06Z</dc:date>
    </item>
    <item>
      <title>Re: sum statement in reports</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sum-statement-in-reports/m-p/1353711#M176892</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hai Kiran &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Read this Document&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SUM. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Effect&lt;/P&gt;&lt;P&gt;When processing an internal table in a block starting with LOOP and concluded by ENDLOOP , SUM calculates the control totals of all fields of type I , F and P (see also ABAP/4 number types ) and places them in the LOOP output area (header line of the internal table or an explicitly specified work area). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use the SUM statement both at the end and the beginning of a control group (see also AT FIRST/LAST ). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example&lt;/P&gt;&lt;P&gt;Display the table T with sub-totals: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: BEGIN OF T OCCURS 100, &lt;/P&gt;&lt;P&gt;CODE(4), &lt;/P&gt;&lt;P&gt;SALES TYPE P, &lt;/P&gt;&lt;P&gt;DISCOUNT TYPE P, &lt;/P&gt;&lt;P&gt;END OF T. &lt;/P&gt;&lt;P&gt;... &lt;/P&gt;&lt;P&gt;LOOP AT T. &lt;/P&gt;&lt;P&gt;AT FIRST. &lt;/P&gt;&lt;P&gt;SUM. &lt;/P&gt;&lt;P&gt;WRITE: /4 'Grand Total:', &lt;/P&gt;&lt;P&gt;20 T-SALES, 40 T-DISCOUNT. &lt;/P&gt;&lt;P&gt;ULINE. SKIP. &lt;/P&gt;&lt;P&gt;ENDAT. &lt;/P&gt;&lt;P&gt;WRITE: / T-CODE, &lt;/P&gt;&lt;P&gt;20 T-SALES, 40 T-DISCOUNT. &lt;/P&gt;&lt;P&gt;AT END OF CODE. &lt;/P&gt;&lt;P&gt;SUM. &lt;/P&gt;&lt;P&gt;WRITE: / T-CODE, 10 'Total:', &lt;/P&gt;&lt;P&gt;20 T-SALES, 40 T-DISCOUNT. &lt;/P&gt;&lt;P&gt;SKIP. &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;Notes&lt;/P&gt;&lt;P&gt;When you use SUM in a LOOP with an explicitly specified output area, this output area must be compatible with the line type of the internal table. &lt;/P&gt;&lt;P&gt;When using LOOP to process a sorted extract (see SORT ), the control total of f at the end of the group appears in the field SUM(f) - - if f is type I , F or P . &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note&lt;/P&gt;&lt;P&gt;Runtime errors &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SUM_OVERFLOW : Value too large when calculatng totals in internal table, field too small. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SUM_NO_INTERNAL_TABLE : The SUM statement was used outside a LOOP on an internal table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SUM_ON_FOREIGN_INTERNAL_TABLE : The SUM statement was used in a LOOP belonging to another ABAP/4 program. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards&lt;/P&gt;&lt;P&gt;Sreenivasulu P&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 May 2006 06:55:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sum-statement-in-reports/m-p/1353711#M176892</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-05-01T06:55:50Z</dc:date>
    </item>
  </channel>
</rss>

