<?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: sorting issues in alv oops in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-issues-in-alv-oops/m-p/6480803#M1418886</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are using &lt;EM&gt;ASCENDING&lt;/EM&gt; sorting type and should be &lt;EM&gt;DESCENDING&lt;/EM&gt; . What I understand is that you want to do sorting in the output (manually in frontend). Therefore you need to use &lt;EM&gt;descending&lt;/EM&gt; sorting option (icon).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to do this using code then use below&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
"fill the ls_sort strcutre 
data: ls_sort type lvc_s_sort.

ls_sort-fieldname = 'FIELDNAME_TO_SORT'.
ls_sort-down = 'X'. "you need descending sorting, not ascending so this one should be used

"then simply pass it to 
call method grid-&amp;gt;set_table_for_first_display
....
 sort = ls_sort

"the output will show rows sorted descending
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Marcin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 20 Jan 2010 19:22:56 GMT</pubDate>
    <dc:creator>MarcinPciak</dc:creator>
    <dc:date>2010-01-20T19:22:56Z</dc:date>
    <item>
      <title>sorting issues in alv oops</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-issues-in-alv-oops/m-p/6480802#M1418885</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Greetings for the Day!!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;am using alv oops for displaying output..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BEFORE sorting my internal table  looks like below in the output.....&lt;/P&gt;&lt;P&gt;for example&lt;/P&gt;&lt;P&gt;A&lt;/P&gt;&lt;P&gt;B&lt;/P&gt;&lt;P&gt;C&lt;/P&gt;&lt;P&gt;D&lt;/P&gt;&lt;P&gt;E&lt;/P&gt;&lt;P&gt;F&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AFTER sorting  the internal table in the output .display.,, the internal table shows like below&lt;/P&gt;&lt;P&gt;F&lt;/P&gt;&lt;P&gt;E&lt;/P&gt;&lt;P&gt;D&lt;/P&gt;&lt;P&gt;C&lt;/P&gt;&lt;P&gt;B&lt;/P&gt;&lt;P&gt;A&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but when i call the method set_table_for_first_display ,after sorting the in the output display ....,the internal table remains as like before&lt;/P&gt;&lt;P&gt;A&lt;/P&gt;&lt;P&gt;B&lt;/P&gt;&lt;P&gt;C&lt;/P&gt;&lt;P&gt;D&lt;/P&gt;&lt;P&gt;E&lt;/P&gt;&lt;P&gt;F....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it should be lke&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;F&lt;/P&gt;&lt;P&gt;E&lt;/P&gt;&lt;P&gt;D&lt;/P&gt;&lt;P&gt;C&lt;/P&gt;&lt;P&gt;B&lt;/P&gt;&lt;P&gt;A .....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;kindly suggest me the alternatives.pls&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Jack&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jan 2010 16:45:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-issues-in-alv-oops/m-p/6480802#M1418885</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-01-20T16:45:57Z</dc:date>
    </item>
    <item>
      <title>Re: sorting issues in alv oops</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-issues-in-alv-oops/m-p/6480803#M1418886</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are using &lt;EM&gt;ASCENDING&lt;/EM&gt; sorting type and should be &lt;EM&gt;DESCENDING&lt;/EM&gt; . What I understand is that you want to do sorting in the output (manually in frontend). Therefore you need to use &lt;EM&gt;descending&lt;/EM&gt; sorting option (icon).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to do this using code then use below&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
"fill the ls_sort strcutre 
data: ls_sort type lvc_s_sort.

ls_sort-fieldname = 'FIELDNAME_TO_SORT'.
ls_sort-down = 'X'. "you need descending sorting, not ascending so this one should be used

"then simply pass it to 
call method grid-&amp;gt;set_table_for_first_display
....
 sort = ls_sort

"the output will show rows sorted descending
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Marcin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jan 2010 19:22:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-issues-in-alv-oops/m-p/6480803#M1418886</guid>
      <dc:creator>MarcinPciak</dc:creator>
      <dc:date>2010-01-20T19:22:56Z</dc:date>
    </item>
    <item>
      <title>Re: sorting issues in alv oops</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-issues-in-alv-oops/m-p/6480804#M1418887</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you saying that you are calling the set_table_for_first_display  method more than one time?  During each PBO execution?  If so, don't.  Do a check before you create the objects in the PBO, if they are not initial, do not re-create them.&lt;/P&gt;&lt;P&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;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jan 2010 19:31:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-issues-in-alv-oops/m-p/6480804#M1418887</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2010-01-20T19:31:10Z</dc:date>
    </item>
    <item>
      <title>Re: sorting issues in alv oops</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-issues-in-alv-oops/m-p/6480805#M1418888</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For example....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: lo_alv_grid            TYPE REF TO cl_gui_alv_grid.
DATA: lo_form_alv_container  TYPE REF TO cl_gui_custom_container.

* Create Controls
    IF lo_form_alv_container IS INITIAL.  "&amp;lt;-- Check if already created

      CREATE OBJECT lo_form_alv_container
        EXPORTING
          container_name = 'FORMULA_CONTAINER'.

* Create control based ALV grid
      CREATE OBJECT lo_alv_grid
        EXPORTING
          i_parent = lo_form_alv_container.

....

* set for first display
      lo_alv_grid-&amp;gt;set_table_for_first_display(
                EXPORTING
                   is_layout            = ls_layout
                   it_toolbar_excluding = lt_exclude
                CHANGING
                   it_outtab            = lt_formulas[]
                   it_fieldcatalog      = lt_fieldcat[] ).

    ELSE.
      lo_alv_grid-&amp;gt;refresh_table_display( ).    "&amp;lt;-- If so, just refresh
    ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jan 2010 19:34:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-issues-in-alv-oops/m-p/6480805#M1418888</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2010-01-20T19:34:37Z</dc:date>
    </item>
    <item>
      <title>Re: sorting issues in alv oops</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-issues-in-alv-oops/m-p/6480806#M1418889</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;set_table_for_first_display has to be called only once. to retain sorting order and filter call refresh_table_display.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However if there is any structure changes on your ALV or for field catalog changes,  you have to make a call again to Set_table_for_first_display, in th at case, you will loose the sort order set by the user previously.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Bhuvana&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Jan 2010 05:52:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-issues-in-alv-oops/m-p/6480806#M1418889</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-01-27T05:52:55Z</dc:date>
    </item>
  </channel>
</rss>

