<?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 internal table logic needed in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-logic-needed/m-p/4805989#M1125112</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i have an internal table with fields like material , plant  , amount etc.&lt;/P&gt;&lt;P&gt;we have plants like mts1,mts1,mts3 etc. and each plant have number of entries like 10 materials preent in mts1 and 20 materials present in mts2 etc and the amounts are also present. now i want to add the amounts for the plant wise. for mts1 there are 10 materials , so i need to add that 10 materials , so tell me how to do it .&lt;/P&gt;&lt;P&gt;is it by at last or by any other method.&lt;/P&gt;&lt;P&gt;or at the time of selecting from the database itself can we do that?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 25 Nov 2008 17:56:56 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-11-25T17:56:56Z</dc:date>
    <item>
      <title>internal table logic needed</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-logic-needed/m-p/4805989#M1125112</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i have an internal table with fields like material , plant  , amount etc.&lt;/P&gt;&lt;P&gt;we have plants like mts1,mts1,mts3 etc. and each plant have number of entries like 10 materials preent in mts1 and 20 materials present in mts2 etc and the amounts are also present. now i want to add the amounts for the plant wise. for mts1 there are 10 materials , so i need to add that 10 materials , so tell me how to do it .&lt;/P&gt;&lt;P&gt;is it by at last or by any other method.&lt;/P&gt;&lt;P&gt;or at the time of selecting from the database itself can we do that?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Nov 2008 17:56:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-logic-needed/m-p/4805989#M1125112</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-11-25T17:56:56Z</dc:date>
    </item>
    <item>
      <title>Re: internal table logic needed</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-logic-needed/m-p/4805990#M1125113</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; i have an internal table with fields like material , plant  , amount etc.&lt;/P&gt;&lt;P&gt;&amp;gt; we have plants like mts1,mts1,mts3 etc. and each plant have number of entries like 10 materials preent in mts1 and 20 materials present in mts2 etc and the amounts are also present. now i want to add the amounts for the plant wise. for mts1 there are 10 materials , so i need to add that 10 materials , so tell me how to do it .&lt;/P&gt;&lt;P&gt;&amp;gt; is it by at last or by any other method.&lt;/P&gt;&lt;P&gt;&amp;gt; or at the time of selecting from the database itself can we do that?&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Loop at &amp;lt;internal table&amp;gt;

at end of plant.
sum.
endat.
endloop,&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Nov 2008 18:00:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-logic-needed/m-p/4805990#M1125113</guid>
      <dc:creator>Mohamed_Mukhtar</dc:creator>
      <dc:date>2008-11-25T18:00:24Z</dc:date>
    </item>
    <item>
      <title>Re: internal table logic needed</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-logic-needed/m-p/4805991#M1125114</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 are using an ALV to display the out(FM : REUSE_ALV_LIST_DISPLAY), all you have to do is to sort the internal table based on plant, and give subtotals field = X in layout and in field catalog give do_sum = X for the fields you want to sum up. (i hope you r familiar with THIS FM). The totals and subtotals will be done automatically.i think this is the easier method&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if you are using standard list output using write statements, then you will have to code for this.. you can use 2 approaches mainly&lt;/P&gt;&lt;P&gt;1) use at end to sum up - but in this case, make sure you have all the records summed up. I have observed while using At end that the last record sometimes does not get added up.in this case , you will have to  take measures to add that too.&lt;/P&gt;&lt;P&gt;2) use an alternate code &lt;/P&gt;&lt;P&gt;sort table by plant.&lt;/P&gt;&lt;P&gt;read table table into wa_temp index 1.&lt;/P&gt;&lt;P&gt;loop at table into wa.&lt;/P&gt;&lt;P&gt;   if wa-plant ne wa_temp-plant.&lt;/P&gt;&lt;P&gt;      wa_temp   =   wa.&lt;/P&gt;&lt;P&gt;      "" here write the code for appending  or writing or anything else as required.&lt;/P&gt;&lt;P&gt;      ""sum = 0.&lt;/P&gt;&lt;P&gt;  endif.&lt;/P&gt;&lt;P&gt;sum = sum + wa-sum.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;"read the last line of the table and take the necessary steps with it if t has not been added up yet.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Nov 2008 18:13:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-logic-needed/m-p/4805991#M1125114</guid>
      <dc:creator>lijisusan_mathews</dc:creator>
      <dc:date>2008-11-25T18:13:47Z</dc:date>
    </item>
    <item>
      <title>Re: internal table logic needed</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-logic-needed/m-p/4805992#M1125115</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;First you select the field into one internal table itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sort them based on plant.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if you are using at end of plant ,you have to make sure that plant is first field in the internal table else &lt;/P&gt;&lt;P&gt;suppose material is the first field in the internal table and plant is second their are 10 diffrent material per plant then your at end of statement will be executed 10 times.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to avoid at end of then you can use ALV .&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_thread" href="https://community.sap.com/" __jive_macro_name="thread" modifiedtitle="true" __default_attr="733537"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards &lt;/P&gt;&lt;P&gt;Neha&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Nov 2008 18:14:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-logic-needed/m-p/4805992#M1125115</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-11-25T18:14:46Z</dc:date>
    </item>
    <item>
      <title>Re: internal table logic needed</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-logic-needed/m-p/4805993#M1125116</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;Maybe you can look the help about these sentences:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;               &lt;STRONG&gt;at first, at last, at end, at new&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;These sentences can help you for solve your problems&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Gregory&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Nov 2008 18:15:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-logic-needed/m-p/4805993#M1125116</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-11-25T18:15:03Z</dc:date>
    </item>
    <item>
      <title>Re: internal table logic needed</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-logic-needed/m-p/4805994#M1125117</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use a numbe of different ways , however I like to maintain sums in separate tables based on the key fields. &lt;/P&gt;&lt;P&gt;1) What you can do is collect this internal table into another internal table. &lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;2) As other have mentioned...use the SUM command with the "at end of" or on change of command, you should however have your table sorted accordingly..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Nov 2008 21:39:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-logic-needed/m-p/4805994#M1125117</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-11-25T21:39:58Z</dc:date>
    </item>
  </channel>
</rss>

