<?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: ALV : problem in subtotal in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-problem-in-subtotal/m-p/4684612#M1101368</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;Then you have to do the subtotal manually, i.e. using at end try like this...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  LOOP AT it_final_d2 INTO wa_final_d2.
    count = count + 1.
    value1 = value1 + wa_final_d2-value.
    ntgew1 = ntgew1 + wa_final_d2-ntgew.
    kwert21 = kwert21 + wa_final_d2-kwert2 .
    diff1 =  diff1 + wa_final_d2-diff.
    value = value + wa_final_d2-value.
    ntgew = ntgew + wa_final_d2-ntgew.
    kwert2 = kwert2 + wa_final_d2-kwert2 .
    diff =  diff + wa_final_d2-diff.
    IF count = 1.
      wa_final-bztxt = wa_final_d2-bztxt.
    ELSE.
      wa_final-bztxt = ' '.
    ENDIF.
    wa_final-oa    = wa_final_d2-oa.
    wa_final-kunnr = wa_final_d2-kunnr.
    wa_final-text  = wa_final_d2-text.
    wa_final-value = wa_final_d2-value.
    wa_final-ntgew = wa_final_d2-ntgew.
    wa_final-ratio = wa_final_d2-ratio.
    wa_final-kwert2 = wa_final_d2-kwert2.
    wa_final-diff  = wa_final_d2-diff.
    wa_final-ratio1 = wa_final_d2-ratio1.
    APPEND wa_final TO it_final.
    AT END OF bztxt.---&amp;gt;this is the subtotal part
      CLEAR count.
      wa_final-bztxt = wa_final_d2-bztxt.
      wa_final-oa    = ' '.
      wa_final-kunnr = ' '.
      wa_final-text  = ' '.
      wa_final-value = value.
      wa_final-ntgew = ntgew.
      wa_final-kwert2 = kwert2.
      wa_final-diff = diff.
      wa_final-ratio = value / ntgew.
      wa_final-ratio1 = diff / ntgew.
      wa_final-line_color = 'C400' . "'C300'.
      APPEND wa_final TO it_final.
      CLEAR : value , ntgew , kwert2 , diff .
      CLEAR wa_final-line_color.
    ENDAT.
  ENDLOOP.

  wa_final-bztxt = 'GRAND SUM'.---&amp;gt;if you want grand total
  wa_final-oa    = ' '.
  wa_final-kunnr = ' '.
  wa_final-text  = ' '.
  wa_final-value = value1.
  wa_final-ntgew = ntgew1.
  wa_final-kwert2 = kwert21.
  wa_final-diff = diff1.
  wa_final-ratio = value1 / ntgew1.
  wa_final-ratio1 = diff1 / ntgew1.
  wa_final-line_color = 'C511'.-----&amp;gt; line colour
  APPEND wa_final TO it_final.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now to get the particular row i.e. subtotal as coloured you have to use like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;declare in your final internal table a field line_color(4) TYPE c,&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
in it_layout pass
it_layout-info_fieldname =      'LINE_COLOR'.
  APPEND it_layout.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and in your final internal table fill line_color as shown above&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 23 Oct 2008 09:45:36 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-10-23T09:45:36Z</dc:date>
    <item>
      <title>ALV : problem in subtotal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-problem-in-subtotal/m-p/4684609#M1101365</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;I am using ALV grid ( FM type, not object-oriented).&lt;/P&gt;&lt;P&gt;the structure is like this...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NAME      |      Allocated     |     Used     |   Percentage |&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am doing a subtotal based on 'NAME'.&lt;/P&gt;&lt;P&gt;the logic for computing 'Percentage' is ' ( Used - Allocated ) / 100'.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The percentage value on the subtotal should be based on the subtotals of&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;column 'Allocated' and 'Used'.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;But I am getting the total of the percentages in subtotal field of percentage......&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I have to highlight the subtotal row also....&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Plz suggest.......&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Akash.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Oct 2008 09:14:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-problem-in-subtotal/m-p/4684609#M1101365</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-23T09:14:09Z</dc:date>
    </item>
    <item>
      <title>Re: ALV : problem in subtotal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-problem-in-subtotal/m-p/4684610#M1101366</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;try this example...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sap-basis-abap.com/sapalv.htm" target="test_blank"&gt;http://www.sap-basis-abap.com/sapalv.htm&lt;/A&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;vivek&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Oct 2008 09:18:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-problem-in-subtotal/m-p/4684610#M1101366</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-23T09:18:47Z</dc:date>
    </item>
    <item>
      <title>Re: ALV : problem in subtotal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-problem-in-subtotal/m-p/4684611#M1101367</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To change the subtotal we need to follow certain steps:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;we need to get the ALV object form the ALV function module. We can use the FM GET_GLOBALS_FROM_SLVC_FULLSCR to get the Global data of the ALV. From this FM we will get the ALV object. &lt;/P&gt;&lt;P&gt;After getting the ALV object, we need to get the subtotal using the method GET_SUBTOTALS of the ALV object. We will get the first level subtotal using the parameter EP_COLLECT01. &lt;/P&gt;&lt;P&gt;Now, we need to modify the subtotal. Here we need to take help of Field-symbols since the EP_COLLECT01 is reference to data. &lt;/P&gt;&lt;P&gt;We need to refresh the Table display. For this purpose we can use the method REFRESH_TABLE_DISPLAY.&lt;/P&gt;&lt;P&gt;Here is the code snippet which performs all the steps mentioned above:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code Snippet to change the Subtotal    &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;  DATA: lo_grid TYPE REF TO cl_gui_alv_grid.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;get the global reference&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'&lt;/P&gt;&lt;P&gt;    IMPORTING&lt;/P&gt;&lt;P&gt;      e_grid = lo_grid.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;get the subtotal&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  DATA: it_01 TYPE REF TO data.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;  CALL METHOD lo_grid-&amp;gt;get_subtotals&lt;/P&gt;&lt;P&gt;    IMPORTING&lt;/P&gt;&lt;P&gt;      ep_collect01 = it_01.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;change the data&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  FIELD-SYMBOLS: &amp;lt;ft_tab&amp;gt; TYPE ANY TABLE,&lt;/P&gt;&lt;P&gt;                 &amp;lt;fs_tab&amp;gt; TYPE ANY,&lt;/P&gt;&lt;P&gt;                 &amp;lt;ff_field&amp;gt; TYPE ANY.&lt;/P&gt;&lt;P&gt;  ASSIGN it_01-&amp;gt;* TO &amp;lt;ft_tab&amp;gt;.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;  LOOP AT &amp;lt;ft_tab&amp;gt; ASSIGNING &amp;lt;fs_tab&amp;gt;.&lt;/P&gt;&lt;P&gt;    ASSIGN COMPONENT 'PER' OF STRUCTURE &amp;lt;fs_tab&amp;gt; TO &amp;lt;ff_field&amp;gt;.&lt;/P&gt;&lt;P&gt;    &amp;lt;ff_field&amp;gt; = '100'.&lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Refresh the table display&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  CALL METHOD lo_grid-&amp;gt;refresh_table_display&lt;/P&gt;&lt;P&gt;    EXPORTING&lt;/P&gt;&lt;P&gt;      i_soft_refresh = 'X'.    &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To be able to use the FM GET_GLOBALS_FROM_SLVC_FULLSCR, we need to find a spot in our program which is being called after the ALV's main FM e.g. REUSE_ALV_GRID_DISPLAY. For this purpose, I have implemented the TOP_OF_PAGE event because it will always be called after the FM. In the subroutine for the TOP_OF_PAGE, I used the code snippet to change the Subtotal.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Oct 2008 09:22:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-problem-in-subtotal/m-p/4684611#M1101367</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-23T09:22:33Z</dc:date>
    </item>
    <item>
      <title>Re: ALV : problem in subtotal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-problem-in-subtotal/m-p/4684612#M1101368</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;Then you have to do the subtotal manually, i.e. using at end try like this...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  LOOP AT it_final_d2 INTO wa_final_d2.
    count = count + 1.
    value1 = value1 + wa_final_d2-value.
    ntgew1 = ntgew1 + wa_final_d2-ntgew.
    kwert21 = kwert21 + wa_final_d2-kwert2 .
    diff1 =  diff1 + wa_final_d2-diff.
    value = value + wa_final_d2-value.
    ntgew = ntgew + wa_final_d2-ntgew.
    kwert2 = kwert2 + wa_final_d2-kwert2 .
    diff =  diff + wa_final_d2-diff.
    IF count = 1.
      wa_final-bztxt = wa_final_d2-bztxt.
    ELSE.
      wa_final-bztxt = ' '.
    ENDIF.
    wa_final-oa    = wa_final_d2-oa.
    wa_final-kunnr = wa_final_d2-kunnr.
    wa_final-text  = wa_final_d2-text.
    wa_final-value = wa_final_d2-value.
    wa_final-ntgew = wa_final_d2-ntgew.
    wa_final-ratio = wa_final_d2-ratio.
    wa_final-kwert2 = wa_final_d2-kwert2.
    wa_final-diff  = wa_final_d2-diff.
    wa_final-ratio1 = wa_final_d2-ratio1.
    APPEND wa_final TO it_final.
    AT END OF bztxt.---&amp;gt;this is the subtotal part
      CLEAR count.
      wa_final-bztxt = wa_final_d2-bztxt.
      wa_final-oa    = ' '.
      wa_final-kunnr = ' '.
      wa_final-text  = ' '.
      wa_final-value = value.
      wa_final-ntgew = ntgew.
      wa_final-kwert2 = kwert2.
      wa_final-diff = diff.
      wa_final-ratio = value / ntgew.
      wa_final-ratio1 = diff / ntgew.
      wa_final-line_color = 'C400' . "'C300'.
      APPEND wa_final TO it_final.
      CLEAR : value , ntgew , kwert2 , diff .
      CLEAR wa_final-line_color.
    ENDAT.
  ENDLOOP.

  wa_final-bztxt = 'GRAND SUM'.---&amp;gt;if you want grand total
  wa_final-oa    = ' '.
  wa_final-kunnr = ' '.
  wa_final-text  = ' '.
  wa_final-value = value1.
  wa_final-ntgew = ntgew1.
  wa_final-kwert2 = kwert21.
  wa_final-diff = diff1.
  wa_final-ratio = value1 / ntgew1.
  wa_final-ratio1 = diff1 / ntgew1.
  wa_final-line_color = 'C511'.-----&amp;gt; line colour
  APPEND wa_final TO it_final.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now to get the particular row i.e. subtotal as coloured you have to use like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;declare in your final internal table a field line_color(4) TYPE c,&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
in it_layout pass
it_layout-info_fieldname =      'LINE_COLOR'.
  APPEND it_layout.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and in your final internal table fill line_color as shown above&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Oct 2008 09:45:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-problem-in-subtotal/m-p/4684612#M1101368</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-23T09:45:36Z</dc:date>
    </item>
    <item>
      <title>Re: ALV : problem in subtotal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-problem-in-subtotal/m-p/4684613#M1101369</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For fieldcat for percentage pass do_sum = 'C'.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Oct 2008 09:49:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-problem-in-subtotal/m-p/4684613#M1101369</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-23T09:49:44Z</dc:date>
    </item>
    <item>
      <title>Re: ALV : problem in subtotal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-problem-in-subtotal/m-p/4684614#M1101370</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;not possible using FM. Use OO-ALV&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Nov 2008 10:02:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-problem-in-subtotal/m-p/4684614#M1101370</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-11-03T10:02:10Z</dc:date>
    </item>
  </channel>
</rss>

