<?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: Need to Sort Subtotal in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-sort-subtotal/m-p/8261090#M1632123</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;Use ALV GRID instead and the user can do further sorting on the output list.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 13 Oct 2011 20:52:07 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-10-13T20:52:07Z</dc:date>
    <item>
      <title>Need to Sort Subtotal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-sort-subtotal/m-p/8261087#M1632120</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 displying output data in ALV List. And I am sorting data and displayed Only SUBTOTAL. And if user want to expand it, than can do it. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have used &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;wa_sort-spos = 1.&lt;/P&gt;&lt;P&gt;wa_sort-fieldname = 'EBELN'.&lt;/P&gt;&lt;P&gt;wa_sort-tabname = 'ITAB'.&lt;/P&gt;&lt;P&gt;wa_sort-subtot = 'X'.&lt;/P&gt;&lt;P&gt;wa_sort-expa = 'X'.&lt;/P&gt;&lt;P&gt;APPEND wa_sort TO it_sort.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now,   I need to sort data which is displaying only Subtotal without Expanding. How can I do that ? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Oct 2011 14:37:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-sort-subtotal/m-p/8261087#M1632120</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-10-13T14:37:48Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Sort Subtotal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-sort-subtotal/m-p/8261088#M1632121</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;Can you be more specific??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Jhings&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Oct 2011 15:20:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-sort-subtotal/m-p/8261088#M1632121</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-10-13T15:20:07Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Sort Subtotal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-sort-subtotal/m-p/8261089#M1632122</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;When user run report , than Output displayed with Subtotals Only. And I want to sort this output. But this Output data for subtotal  is not saved in any table . Its displayed because I pass parameter It_sort to ALV List Function Module.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So , How can I can sort This subtotal output data ? Plz anybody is having any Idea ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Oct 2011 18:52:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-sort-subtotal/m-p/8261089#M1632122</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-10-13T18:52:36Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Sort Subtotal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-sort-subtotal/m-p/8261090#M1632123</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;Use ALV GRID instead and the user can do further sorting on the output list.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Oct 2011 20:52:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-sort-subtotal/m-p/8261090#M1632123</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-10-13T20:52:07Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Sort Subtotal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-sort-subtotal/m-p/8261091#M1632124</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;wa_sort has a property &lt;STRONG&gt;up&lt;/STRONG&gt; &amp;amp; &lt;STRONG&gt;down&lt;/STRONG&gt;.Pass X to relevant property.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Oct 2011 03:57:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-sort-subtotal/m-p/8261091#M1632124</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2011-10-14T03:57:46Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Sort Subtotal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-sort-subtotal/m-p/8261092#M1632125</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;through this I can sort ( descending )detail data .  But I need to sort these subtotal data . &lt;/P&gt;&lt;P&gt;suppose I have given one example below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;                ebeln                     menge&lt;/P&gt;&lt;P&gt;               100001                    4&lt;/P&gt;&lt;P&gt;               100001                    6&lt;/P&gt;&lt;P&gt;               100001                    5&lt;/P&gt;&lt;P&gt;subtotal  100001                   15&lt;/P&gt;&lt;P&gt;               100002                   2&lt;/P&gt;&lt;P&gt;               100002                   7&lt;/P&gt;&lt;P&gt;              100002                    8&lt;/P&gt;&lt;P&gt;subtotal  100002                   17.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now if I sort (decending) than its sorting only detail data means output will be&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;                ebeln                     menge&lt;/P&gt;&lt;P&gt;               100001                    6&lt;/P&gt;&lt;P&gt;               100001                    5&lt;/P&gt;&lt;P&gt;               100001                    4&lt;/P&gt;&lt;P&gt;subtotal  100001                   15&lt;/P&gt;&lt;P&gt;               100002                   8&lt;/P&gt;&lt;P&gt;               100002                   7&lt;/P&gt;&lt;P&gt;              100002                    2&lt;/P&gt;&lt;P&gt;subtotal  100002                   17.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I need to sort (descending) subtotal item means i should display like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;                ebeln                        menge&lt;/P&gt;&lt;P&gt;subtotal   100002                      17&lt;/P&gt;&lt;P&gt;subtotal    100001                     15&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope now its more undestandable........&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Oct 2011 06:07:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-sort-subtotal/m-p/8261092#M1632125</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-10-14T06:07:29Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Sort Subtotal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-sort-subtotal/m-p/8261093#M1632126</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;if you use &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; wa_sort-spos = 1.
wa_sort-fieldname = 'EBELN'.
wa_sort-tabname = 'ITAB'.
wa_sort-subtot = 'X'.
wa_sort-down = 'X
wa_sort-expa = 'X'.
APPEND wa_sort TO it_sort.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; it will give out put like &lt;/P&gt;&lt;P&gt;ebeln menge&lt;/P&gt;&lt;P&gt;subtotal 100002 17&lt;/P&gt;&lt;P&gt;subtotal 100001 15&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Oct 2011 06:39:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-sort-subtotal/m-p/8261093#M1632126</guid>
      <dc:creator>lijisusan_mathews</dc:creator>
      <dc:date>2011-10-14T06:39:09Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Sort Subtotal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-sort-subtotal/m-p/8261094#M1632127</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 dont see a standard method for just sorting the subtotals only, you can do some thing programatically if this is a necessary business reuirement. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

TYPE-POOLS:slis.

TYPES:BEGIN OF ty,
      ebeln TYPE ekpo-ebeln,
      val TYPE i,
      END OF ty.
DATA:it4 TYPE SORTED TABLE OF ty WITH NON-UNIQUE KEY ebeln.
DATA:it TYPE TABLE OF ty.
DATA:it1 TYPE TABLE OF ty.
DATA:it2 TYPE TABLE OF ty.
DATA:it3 TYPE TABLE OF ty.
DATA:wa TYPE ty,
     wa2 TYPE ty,
     i_fieldcat TYPE slis_t_fieldcat_alv,
     i_sort TYPE  slis_t_sortinfo_alv,
     wa_sort TYPE slis_sortinfo_alv,
     wa_lfl_fcat    TYPE  slis_fieldcat_alv.


START-OF-SELECTION.

  wa-ebeln = '100009'.wa-val = '10'.APPEND wa TO it.wa-val = '10'.APPEND wa TO it.wa-val = '10'.APPEND wa TO it.
  wa-ebeln = '100001'.wa-val = '4'.APPEND wa TO it.wa-val = '6'.APPEND wa TO it.  wa-val = '5'.APPEND wa TO it.
  wa-ebeln = '100006'.wa-val = '1'.APPEND wa TO it.wa-val = '1'.APPEND wa TO it.  wa-val = '1'.APPEND wa TO it.
  wa-ebeln = '100002'.wa-val = '2'.APPEND wa TO it.wa-val = '7'.APPEND wa TO it.  wa-val = '8'.APPEND wa TO it.

  SORT it BY ebeln.
  APPEND LINES OF it TO it4.

  LOOP AT it INTO wa.
    COLLECT wa INTO it2.
  ENDLOOP.

  SORT it2 BY val DESCENDING.

  LOOP AT it2 INTO wa2.
    LOOP AT it4 INTO wa WHERE ebeln = wa2-ebeln.
      APPEND wa TO it3.
    ENDLOOP.
  ENDLOOP.

  wa_lfl_fcat-fieldname =  'EBELN'.
  APPEND wa_lfl_fcat TO i_fieldcat.
  wa_lfl_fcat-fieldname =  'VAL'.
  wa_lfl_fcat-do_sum  = 'X'.
  APPEND wa_lfl_fcat TO i_fieldcat.

  wa_sort-fieldname = 'EBELN'.
  wa_sort-subtot = 'X'.
  APPEND wa_sort TO i_sort .


  DATA:l_repid TYPE sy-repid.
  l_repid = sy-repid.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
            i_callback_program = l_repid
            it_fieldcat        = i_fieldcat
            it_sort            = i_sort
       TABLES
            t_outtab           = it3  "this itab holds values as you desired, but dont know why its not getting replicated in the output.
       EXCEPTIONS
            program_error      = 1
            OTHERS             = 2.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Oct 2011 06:49:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-sort-subtotal/m-p/8261094#M1632127</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2011-10-14T06:49:28Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Sort Subtotal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-sort-subtotal/m-p/8261095#M1632128</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi  Suzie.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here You have mentioned EBELN.  But i need to sort based On MENGE . tHAN ITS WORK ? Or need to SORT For MENGE also..&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, 14 Oct 2011 06:54:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-sort-subtotal/m-p/8261095#M1632128</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-10-14T06:54:48Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Sort Subtotal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-sort-subtotal/m-p/8261096#M1632129</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;Execute the program in your system once and check. If you see it3 the data is as you needed and i have not given a sort to EBELN. But in display it sorts in ascending order by default. I think this happens internally&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if you comment&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
*  wa_sort-fieldname = 'EBELN'.
*  wa_sort-up = ' '.
*  wa_sort-down = ' '.
*  wa_sort-subtot = 'X'.
*  APPEND wa_sort TO i_sort .
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you will understand&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My bad:it makes sense "Without sorting how will the grouping for subtotal happen !!!" Thats why it happens internally&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kesav&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Keshav.T on Oct 14, 2011 12:33 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Oct 2011 06:57:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-sort-subtotal/m-p/8261096#M1632129</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2011-10-14T06:57:29Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Sort Subtotal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-sort-subtotal/m-p/8261097#M1632130</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;But I need to sort (descending) subtotal item means i should display like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ebeln menge&lt;/P&gt;&lt;P&gt;subtotal 100002 17&lt;/P&gt;&lt;P&gt;subtotal 100001 15&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And why would someone want to do this? Standard ALV doesn't cater to this requirement. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alternatively you can display the subtotal as the basic list(which you can SORT et al.) &amp;amp; based on some user interaction display the detailed list with the break down of the sub-total.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope you get the point.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Suhas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Oct 2011 06:58:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-sort-subtotal/m-p/8261097#M1632130</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2011-10-14T06:58:01Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Sort Subtotal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-sort-subtotal/m-p/8261098#M1632131</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For time being this willl work, but there is a limit for field &lt;STRONG&gt;in&lt;/STRONG&gt; in structure ty1. may be creating the internal table dynamically with field IN (n equal to the no of rows in internal table it2 )might help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
TYPE-POOLS:slis.

TYPES:BEGIN OF ty,
      ebeln TYPE ekpo-ebeln,
      val TYPE i,
      END OF ty.
TYPES:BEGIN OF ty1,
      in(1234) TYPE c,
      ebeln TYPE ekpo-ebeln,
      val TYPE i,
      END OF ty1.

DATA:it4 TYPE SORTED TABLE OF ty WITH NON-UNIQUE KEY ebeln.
DATA:it TYPE TABLE OF ty.
DATA:it1 TYPE TABLE OF ty.
DATA:it2 TYPE TABLE OF ty.
DATA:it3 TYPE TABLE OF ty1.
DATA:wa TYPE ty,
     wa2 TYPE ty,
     wa3 TYPE ty1,
     i_fieldcat TYPE slis_t_fieldcat_alv,
     i_sort TYPE  slis_t_sortinfo_alv,
     wa_sort TYPE slis_sortinfo_alv,
     wa_lfl_fcat    TYPE  slis_fieldcat_alv.


START-OF-SELECTION.

  wa-ebeln = '100009'.
  wa-val = '10'.APPEND wa TO it.wa-val = '10'.APPEND wa TO it.
  wa-val = '10'.APPEND wa TO it.
  wa-ebeln = '100001'.
  wa-val = '4'.APPEND wa TO it.wa-val = '6'.APPEND wa TO it.
  wa-val = '5'.APPEND wa TO it.
  wa-ebeln = '100006'.
  wa-val = '1'.APPEND wa TO it.wa-val = '1'.APPEND wa TO it.
  wa-val = '1'.APPEND wa TO it.
  wa-ebeln = '100002'.
  wa-val = '2'.APPEND wa TO it.wa-val = '7'.APPEND wa TO it.
  wa-val = '8'.APPEND wa TO it.

  SORT it BY ebeln.
  APPEND LINES OF it TO it4.

  LOOP AT it INTO wa.
    COLLECT wa INTO it2.
  ENDLOOP.

  SORT it2 BY val DESCENDING.
  DATA:l_tabix TYPE i.
  l_tabix = 0.
  LOOP AT it2 INTO wa2.
    l_tabix = l_tabix + 1.
    LOOP AT it4 INTO wa WHERE ebeln = wa2-ebeln.
      wa3-ebeln = wa-ebeln.
      wa3-val = wa-val.
      wa3-in = l_tabix.
      APPEND wa3 TO it3.
    ENDLOOP.
  ENDLOOP.

  sort it3 by in descending.

  wa_lfl_fcat-fieldname =  'IN'.
  wa_lfl_fcat-no_out =  'X'.
  APPEND wa_lfl_fcat TO i_fieldcat.
  clear wa_lfl_fcat.
  wa_lfl_fcat-fieldname =  'EBELN'.
  APPEND wa_lfl_fcat TO i_fieldcat.
  clear wa_lfl_fcat.
  wa_lfl_fcat-fieldname =  'VAL'.
  wa_lfl_fcat-do_sum  = 'X'.
  APPEND wa_lfl_fcat TO i_fieldcat.

  wa_sort-fieldname = 'IN'.
  wa_sort-subtot = 'X'.
  wa_sort-up = 'X'.
  APPEND wa_sort TO i_sort .


  DATA:l_repid TYPE sy-repid.
  l_repid = sy-repid.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
            i_callback_program = l_repid
            it_fieldcat        = i_fieldcat
            it_sort            = i_sort
       TABLES
            t_outtab           = it3[]
       EXCEPTIONS
            program_error      = 1
            OTHERS             = 2.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Oct 2011 07:15:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-sort-subtotal/m-p/8261098#M1632131</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2011-10-14T07:15:39Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Sort Subtotal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-sort-subtotal/m-p/8261099#M1632132</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sort for EBELN as descending and MENGE ascending. it WILL solve your problem&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Oct 2011 07:28:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-sort-subtotal/m-p/8261099#M1632132</guid>
      <dc:creator>lijisusan_mathews</dc:creator>
      <dc:date>2011-10-14T07:28:23Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Sort Subtotal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-sort-subtotal/m-p/8261100#M1632133</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kechsav ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Its really nice piece of coding.&lt;/P&gt;&lt;P&gt;Here I have added  &lt;/P&gt;&lt;P&gt; wa_sort-expa = 'X'.  So , its only Subtotal desplay and it can be expandable. Now problem is that There is not Subtotal text is displayed It shoul d be ebeln .  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Means these subtotal of menge should be displayed  with name of ebeln.  &lt;/P&gt;&lt;P&gt;&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, 14 Oct 2011 08:15:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-sort-subtotal/m-p/8261100#M1632133</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-10-14T08:15:47Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Sort Subtotal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-sort-subtotal/m-p/8261101#M1632134</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try it with RS_TREE_LIST_DISPLAY. Its not possible the way you expect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kesav&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Oct 2011 09:01:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-sort-subtotal/m-p/8261101#M1632134</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2011-10-14T09:01:05Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Sort Subtotal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-sort-subtotal/m-p/8261102#M1632135</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check this...It will work  "Dont forget to diable the sort and sum buttons in the standard tool bar :)'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
REPORT ytest_str11.

TYPE-POOLS:slis.

TYPES:BEGIN OF ty,
      ebeln TYPE ekpo-ebeln,
      val TYPE i,
      END OF ty.
TYPES:BEGIN OF ty1,
      in(1234) TYPE c,
      ebeln TYPE ekpo-ebeln,
      val TYPE i,
      END OF ty1.
DATA:g_tabix TYPE i.
DATA:it4 TYPE SORTED TABLE OF ty WITH NON-UNIQUE KEY ebeln.
DATA:it TYPE TABLE OF ty.
DATA:it2 TYPE TABLE OF ty.
DATA:it3 TYPE TABLE OF ty1.
DATA:wa TYPE ty,
     wa2 TYPE ty,
     wa3 TYPE ty1,
     i_fieldcat TYPE slis_t_fieldcat_alv,
     i_sort TYPE  slis_t_sortinfo_alv,
     wa_sort TYPE slis_sortinfo_alv,
     wa_lfl_fcat    TYPE  slis_fieldcat_alv,
     i_alv_top_of_page TYPE slis_t_listheader,
     i_events TYPE slis_t_event,
     i_event TYPE slis_t_event,
     wa_events         TYPE slis_alv_event.


START-OF-SELECTION.

  wa-ebeln = '100009'.
  wa-val = '10'.APPEND wa TO it.wa-val = '10'.APPEND wa TO it.
  wa-val = '10'.APPEND wa TO it.
  wa-ebeln = '100001'.
  wa-val = '4'.APPEND wa TO it.wa-val = '6'.APPEND wa TO it.
  wa-val = '5'.APPEND wa TO it.
  wa-ebeln = '100006'.
  wa-val = '1'.APPEND wa TO it.wa-val = '1'.APPEND wa TO it.
  wa-val = '1'.APPEND wa TO it.
  wa-ebeln = '100002'.
  wa-val = '2'.APPEND wa TO it.wa-val = '7'.APPEND wa TO it.
  wa-val = '8'.APPEND wa TO it.

  SORT it BY ebeln.
  APPEND LINES OF it TO it4.

  LOOP AT it INTO wa.
    COLLECT wa INTO it2.
  ENDLOOP.

  SORT it2 BY val DESCENDING.
  DATA:l_tabix(1234) TYPE c.
  l_tabix = 0.
  LOOP AT it2 INTO wa2.
    l_tabix = l_tabix + 1.
    SHIFT l_tabix LEFT DELETING LEADING space.
    LOOP AT it4 INTO wa WHERE ebeln = wa2-ebeln.
      wa3-ebeln = wa-ebeln.
      wa3-val = wa-val.
      wa3-in = l_tabix.
      APPEND wa3 TO it3.
    ENDLOOP.
  ENDLOOP.

  wa_lfl_fcat-fieldname =  'IN'.
  wa_lfl_fcat-no_out =  'X'.
  APPEND wa_lfl_fcat TO i_fieldcat.
  CLEAR wa_lfl_fcat.
  wa_lfl_fcat-fieldname =  'EBELN'.
  APPEND wa_lfl_fcat TO i_fieldcat.
  CLEAR wa_lfl_fcat.
  wa_lfl_fcat-fieldname =  'VAL'.
  wa_lfl_fcat-do_sum  = 'X'.
  APPEND wa_lfl_fcat TO i_fieldcat.

  wa_sort-fieldname = 'IN'.
  wa_sort-subtot = 'X'.
  wa_sort-up = 'X'.
  wa_sort-expa = 'X'.
  APPEND wa_sort TO i_sort .

  DATA:l_repid TYPE sy-repid.
  l_repid = sy-repid.
  DATA: l_s_event TYPE slis_alv_event.

  l_s_event-form = 'SUBTOTAL_TEXT'.
  l_s_event-name = 'SUBTOTAL_TEXT'.
  APPEND l_s_event TO i_event.

  data:lv_lines type i.
  describe table it2 lines lv_lines.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
            i_callback_program = l_repid
            it_fieldcat        = i_fieldcat
            it_sort            = i_sort
            it_events          = i_event
       TABLES
            t_outtab           = it3[]
       EXCEPTIONS
            program_error      = 1
            OTHERS             = 2.

*---------------------------------------------------------------------*
*       FORM subtotal_text                                            *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  --&amp;gt;  P_TOTAL                                                       *
*  --&amp;gt;  P_SUBTOT_TEXT                                                 *
*---------------------------------------------------------------------*
FORM subtotal_text CHANGING
               p_total TYPE any
               p_subtot_text TYPE slis_subtot_text.

  if g_tabix = lv_lines.
  g_tabix = 0.
  endif.

  g_tabix = g_tabix + 1.
  IF p_subtot_text-criteria = 'IN'.
    READ TABLE it2 INTO wa2 INDEX g_tabix.
    IF sy-subrc = 0.
      p_subtot_text-display_text_for_subtotal = wa2-ebeln.
    ENDIF.

  ENDIF.

ENDFORM.                    "subtotal_text
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Keshav.T on Oct 14, 2011 3:04 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Oct 2011 09:29:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-sort-subtotal/m-p/8261102#M1632135</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2011-10-14T09:29:29Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Sort Subtotal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-sort-subtotal/m-p/8261103#M1632136</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi keshav , &lt;/P&gt;&lt;P&gt;Thanks for needful coding .  Its has been solved by Sutotal_text event.&lt;/P&gt;&lt;P&gt;And thanks to all fo your Comment.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Oct 2011 15:19:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-sort-subtotal/m-p/8261103#M1632136</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-10-14T15:19:02Z</dc:date>
    </item>
  </channel>
</rss>

