<?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: internal table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table/m-p/3853660#M926369</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;you can also work with add ..field2 to sum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;Nicole&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 16 May 2008 06:53:18 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-05-16T06:53:18Z</dc:date>
    <item>
      <title>internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table/m-p/3853659#M926368</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Loop at itab into &amp;lt;wa&amp;gt;&lt;/P&gt;&lt;P&gt;   Here I want to sum all &amp;lt;wa&amp;gt;-field2&lt;/P&gt;&lt;P&gt;   Can I use&lt;/P&gt;&lt;P&gt;   compute sum = sum + &amp;lt;wa-field2&amp;gt; &lt;/P&gt;&lt;P&gt;Endloop&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is there a more elegant method&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 May 2008 06:48:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table/m-p/3853659#M926368</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-16T06:48:47Z</dc:date>
    </item>
    <item>
      <title>Re: internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table/m-p/3853660#M926369</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;you can also work with add ..field2 to sum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;Nicole&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 May 2008 06:53:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table/m-p/3853660#M926369</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-16T06:53:18Z</dc:date>
    </item>
    <item>
      <title>Re: internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table/m-p/3853661#M926370</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;if you have internal table table like this&lt;/P&gt;&lt;P&gt;aa bb cc n sum&lt;/P&gt;&lt;P&gt;xxx xxx xxx 2&lt;/P&gt;&lt;P&gt;yyy yyy yyy 3&lt;/P&gt;&lt;P&gt;zzz zzz zzz 4 9&lt;/P&gt;&lt;P&gt;to get the sum of sevaral data in the same line&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use this...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;codedata: total_SUM type f.&lt;/P&gt;&lt;P&gt;SELECT SUM( sum ) INTO total_SUM&lt;/P&gt;&lt;P&gt;FROM itab&lt;/P&gt;&lt;P&gt;WHERE&lt;/P&gt;&lt;P&gt;aa = 'xxx' AND&lt;/P&gt;&lt;P&gt;bb = 'xxx'.[/code]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check this link...&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/select_c.htm" target="test_blank"&gt;http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/select_c.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can also check a simillar demo  program in se38.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;DEMO_EXTRACT_CNT_SUM.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Raj.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 May 2008 06:56:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table/m-p/3853661#M926370</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-16T06:56:01Z</dc:date>
    </item>
    <item>
      <title>Re: internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table/m-p/3853662#M926371</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;U can ur method to get the sum. But do remember to clear the &amp;lt;wa-field2&amp;gt; after sum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 May 2008 06:58:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table/m-p/3853662#M926371</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-16T06:58:10Z</dc:date>
    </item>
    <item>
      <title>Re: internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table/m-p/3853663#M926372</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;      If u want to add the values of work area u can use &lt;/P&gt;&lt;P&gt;Collect statement .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT sflight_tab INTO sflight_wa. &lt;/P&gt;&lt;P&gt;  AT NEW connid. &lt;/P&gt;&lt;P&gt;    WRITE: / sflight_wa-carrid, &lt;/P&gt;&lt;P&gt;             sflight_wa-connid. &lt;/P&gt;&lt;P&gt;    ULINE. &lt;/P&gt;&lt;P&gt;  ENDAT. &lt;/P&gt;&lt;P&gt;  WRITE: / sflight_wa-fldate, &lt;/P&gt;&lt;P&gt;           sflight_wa-seatsocc. &lt;/P&gt;&lt;P&gt;  AT END OF connid. &lt;/P&gt;&lt;P&gt;    SUM. &lt;/P&gt;&lt;P&gt;    ULINE. &lt;/P&gt;&lt;P&gt;    WRITE: / 'Sum', &lt;/P&gt;&lt;P&gt;              sflight_wa-seatsocc UNDER sflight_wa-seatsocc. &lt;/P&gt;&lt;P&gt;    SKIP. &lt;/P&gt;&lt;P&gt;  ENDAT. &lt;/P&gt;&lt;P&gt;  AT END OF carrid. &lt;/P&gt;&lt;P&gt;    SUM. &lt;/P&gt;&lt;P&gt;    ULINE. &lt;/P&gt;&lt;P&gt;    WRITE: / 'Carrier Sum', &lt;/P&gt;&lt;P&gt;              sflight_wa-seatsocc UNDER sflight_wa-seatsocc. &lt;/P&gt;&lt;P&gt;    NEW-PAGE. &lt;/P&gt;&lt;P&gt;  ENDAT. &lt;/P&gt;&lt;P&gt;  AT LAST. &lt;/P&gt;&lt;P&gt;    SUM. &lt;/P&gt;&lt;P&gt;    WRITE: / 'Overall Sum', &lt;/P&gt;&lt;P&gt;              sflight_wa-seatsocc UNDER sflight_wa-seatsocc. &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;This is just an  example ........&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 May 2008 07:00:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table/m-p/3853663#M926372</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-16T07:00:47Z</dc:date>
    </item>
    <item>
      <title>Re: internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table/m-p/3853664#M926373</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. sum = add &amp;lt;wa&amp;gt;-field2 to sum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. sum = sum + &amp;lt;wa&amp;gt;-field2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. use the keyword "SUM". It is used in this way :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The statement SUM can only be specified within a loop starting with LOOP, and is only considered within a AT- ENDAT control structure. Prerequisites for using the statement SUM include using the addition INTO in the LOOP statement, and that the specified work area wa is compatible with the row type of the internal table. In addition, SUM cannot be used when the row type of the internal table itab contains components that are tables. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The statement SUM calculates the component total with the numeric data type (i, p, f) of all rows in the current control level and assigns these to the components of the work area wa. In the control levels FIRST, LAST, and outside of an AT-ENDAT control structure, the system calculates the sum of numeric components of all rows in the internal table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please see if this is helpful!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 May 2008 07:02:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table/m-p/3853664#M926373</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-16T07:02:00Z</dc:date>
    </item>
    <item>
      <title>Re: internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table/m-p/3853665#M926374</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;If you want to add only a particular field irrespective of the key fields in the table, your code is Ok. Incase you want add the fields based on certain key fields, just declare another internal table with same structure with key addition, mention the key fields. Now loop at the main internal table, assign the workarea to new one, use collect wa to internal table will sum all the numeric field in it and keep a single record for a key field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ex.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;types: begin of ty_xxx,&lt;/P&gt;&lt;P&gt;             yyy type c,&lt;/P&gt;&lt;P&gt;             zzz type c,&lt;/P&gt;&lt;P&gt;             aaa type i,&lt;/P&gt;&lt;P&gt;          end of ty_xxx.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: i_tab type table of ty_xxx with key yyy zzz.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab into wa.&lt;/P&gt;&lt;P&gt;     move wa to wa_new.&lt;/P&gt;&lt;P&gt;     collect wa_new into i_tab.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;itab:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A  B  10&lt;/P&gt;&lt;P&gt;A  B  20&lt;/P&gt;&lt;P&gt;B  C  30 &lt;/P&gt;&lt;P&gt;B  C  40&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i_tab:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A  B  30&lt;/P&gt;&lt;P&gt;B  C  70 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Muthu.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 May 2008 07:03:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table/m-p/3853665#M926374</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-16T07:03:46Z</dc:date>
    </item>
  </channel>
</rss>

