<?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 Compute average in ALV using do_sum using different columns in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/compute-average-in-alv-using-do-sum-using-different-columns/m-p/6902996#M1481650</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know that the fieldcat-do_sum = 'C' calculates average of specified column in ALV. But is there a possibility that it computes average of two other columns? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's an example of a scenario I was talking about.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Column A values:&lt;/P&gt;&lt;P&gt;100&lt;/P&gt;&lt;P&gt;200&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-----" /&gt;&lt;P&gt;300 - Total amount&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Column B values:&lt;/P&gt;&lt;P&gt;500&lt;/P&gt;&lt;P&gt;100&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-----" /&gt;&lt;P&gt;600 - Total amount&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Column C values:&lt;/P&gt;&lt;P&gt;400&lt;/P&gt;&lt;P&gt;100&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="------" /&gt;&lt;P&gt;250 - Average (Here's where do_sum was declared)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The expected output should be displayed in Column C but it needs to calculate B / A, ( 600 / 300 ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any suggestion will highly appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Aura&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 17 May 2010 11:04:24 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-05-17T11:04:24Z</dc:date>
    <item>
      <title>Compute average in ALV using do_sum using different columns</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/compute-average-in-alv-using-do-sum-using-different-columns/m-p/6902996#M1481650</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know that the fieldcat-do_sum = 'C' calculates average of specified column in ALV. But is there a possibility that it computes average of two other columns? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's an example of a scenario I was talking about.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Column A values:&lt;/P&gt;&lt;P&gt;100&lt;/P&gt;&lt;P&gt;200&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-----" /&gt;&lt;P&gt;300 - Total amount&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Column B values:&lt;/P&gt;&lt;P&gt;500&lt;/P&gt;&lt;P&gt;100&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-----" /&gt;&lt;P&gt;600 - Total amount&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Column C values:&lt;/P&gt;&lt;P&gt;400&lt;/P&gt;&lt;P&gt;100&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="------" /&gt;&lt;P&gt;250 - Average (Here's where do_sum was declared)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The expected output should be displayed in Column C but it needs to calculate B / A, ( 600 / 300 ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any suggestion will highly appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Aura&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 May 2010 11:04:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/compute-average-in-alv-using-do-sum-using-different-columns/m-p/6902996#M1481650</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-05-17T11:04:24Z</dc:date>
    </item>
    <item>
      <title>Re: Compute average in ALV using do_sum using different columns</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/compute-average-in-alv-using-do-sum-using-different-columns/m-p/6902997#M1481651</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, it´s possible. What type of ALV you are using? ALV_GRID or ALV_LIST?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- In ALV_LIST you can manipulate the data before is printed on screen, by event BEFORE_OUTPUT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- In ALV_GRID you can create a class and redefine the method  set_data_table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Leandro Mengue&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 May 2010 19:12:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/compute-average-in-alv-using-do-sum-using-different-columns/m-p/6902997#M1481651</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-05-19T19:12:59Z</dc:date>
    </item>
    <item>
      <title>Re: Compute average in ALV using do_sum using different columns</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/compute-average-in-alv-using-do-sum-using-different-columns/m-p/6902998#M1481652</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I had to calculate average in totals for a ALV report. This is how I achieved this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
* Change Total
  FIELD-SYMBOLS:
  &amp;lt;FT_TAB&amp;gt;   TYPE ANY TABLE,
  &amp;lt;FS_TAB&amp;gt;   TYPE ANY,
  &amp;lt;GAMNG&amp;gt;    TYPE ANY,
  &amp;lt;FKIMG&amp;gt;   TYPE ANY,
  &amp;lt;FAILRATE&amp;gt; TYPE ANY.

  TRY.
      CALL METHOD G_ALV-&amp;gt;GET_SUBTOTALS
        IMPORTING
          EP_COLLECT00 = IT_01.

    CATCH CX_SY_REF_IS_INITIAL INTO LREF_EXCEP.
  ENDTRY.

  ASSIGN IT_01-&amp;gt;* TO &amp;lt;FT_TAB&amp;gt;.

  LOOP AT &amp;lt;FT_TAB&amp;gt; ASSIGNING &amp;lt;FS_TAB&amp;gt;.
    ASSIGN COMPONENT 'FKIMG' OF STRUCTURE &amp;lt;FS_TAB&amp;gt; TO &amp;lt;FKIMG&amp;gt;.
    ASSIGN COMPONENT 'GAMNG'  OF STRUCTURE &amp;lt;FS_TAB&amp;gt; TO &amp;lt;GAMNG&amp;gt;.
    ASSIGN COMPONENT 'FAILRATE' OF STRUCTURE &amp;lt;FS_TAB&amp;gt; TO &amp;lt;FAILRATE&amp;gt;.
    IF &amp;lt;GAMNG&amp;gt; IS NOT INITIAL AND &amp;lt;FKIMG&amp;gt; IS NOT INITIAL.
      V_FAILRATE = ( &amp;lt;GAMNG&amp;gt; / &amp;lt;FKIMG&amp;gt; ) * 100.
      V_FAILRATE = V_FAILRATE * V_DATEDIF.
      &amp;lt;FAILRATE&amp;gt; = V_FAILRATE.
    ENDIF.
  ENDLOOP.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to change subtotals you can call the method with EP_COLLECT01 instead of EP_COLLECT00&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 May 2010 21:38:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/compute-average-in-alv-using-do-sum-using-different-columns/m-p/6902998#M1481652</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-05-19T21:38:34Z</dc:date>
    </item>
  </channel>
</rss>

