<?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 how to use sort using abap objects in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-sort-using-abap-objects/m-p/3051691#M722528</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hello friends,&lt;/P&gt;&lt;P&gt;i am using the class cl_salv_table to display my ALV. now on my selection screen i have 3 radio buttons,according to the radiobutton selected my output should appear sorted.&lt;/P&gt;&lt;P&gt;which class can help me sort my internal fields according to the radio button on the selection screen and pls tell me how to do this.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 27 Nov 2007 07:39:50 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-11-27T07:39:50Z</dc:date>
    <item>
      <title>how to use sort using abap objects</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-sort-using-abap-objects/m-p/3051691#M722528</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hello friends,&lt;/P&gt;&lt;P&gt;i am using the class cl_salv_table to display my ALV. now on my selection screen i have 3 radio buttons,according to the radiobutton selected my output should appear sorted.&lt;/P&gt;&lt;P&gt;which class can help me sort my internal fields according to the radio button on the selection screen and pls tell me how to do this.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Nov 2007 07:39:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-sort-using-abap-objects/m-p/3051691#M722528</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-11-27T07:39:50Z</dc:date>
    </item>
    <item>
      <title>Re: how to use sort using abap objects</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-sort-using-abap-objects/m-p/3051692#M722529</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Amit,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You must use the methods GET_SORTS and ADD_SORT of class CL_SALV_SORTS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can get more explanation on &amp;lt;a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/5dc3e690-0201-0010-1ebf-b85b3bed962d"&amp;gt;SAP List Viewer Document&amp;lt;/a&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is an example, i hope it useful for you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
REPORT zsalv_sort_mar NO STANDARD PAGE HEADING.

*----------------------------------------------------------------------*
*       CLASS lcl_alv DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_alv DEFINITION.
  PUBLIC SECTION.

    METHODS select_alv IMPORTING amount TYPE i.

    METHODS display_alv IMPORTING columnname TYPE lvc_fname.

  PROTECTED SECTION.

    DATA: o_table   TYPE REF TO cl_salv_table,
          " We Must create an object of cl_salv_sorts to sort table
          o_sorts   TYPE REF TO cl_salv_sorts,
          o_columns TYPE REF TO cl_salv_columns_table.

    DATA t_alv TYPE STANDARD TABLE OF alv_tab.

ENDCLASS.                    "lcl_alv DEFINITION

*----------------------------------------------------------------------*
*       CLASS lcl_alv IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_alv IMPLEMENTATION.

  METHOD select_alv.

    SELECT *
      FROM alv_tab
      INTO CORRESPONDING FIELDS OF TABLE t_alv
          UP TO amount ROWS.

  ENDMETHOD.                    "SELECT_ALV

  METHOD display_alv.

    TRY.
        cl_salv_table=&amp;gt;factory(
          IMPORTING
            r_salv_table = o_table
          CHANGING
            t_table      = t_alv ).
      CATCH cx_salv_msg.
    ENDTRY.

    o_columns = o_table-&amp;gt;get_columns( ).
    o_columns-&amp;gt;set_optimize( abap_true ).

    "Here we're getting all sortable field
    o_sorts = o_table-&amp;gt;get_sorts( ).
    "COLUMNNAME contais 'CARRNAME' that will be used to the sort Table  
    o_sorts-&amp;gt;add_sort( COLUMNNAME ).
    o_table-&amp;gt;display( ).

  ENDMETHOD.                    "display_alv

ENDCLASS.                    "lcl_alv IMPLEMENTATION

DATA o_alv TYPE REF TO lcl_alv.

START-OF-SELECTION.

  CREATE OBJECT o_alv.

  o_alv-&amp;gt;select_alv( 30 ).
 "Displaye alv Sorting by field 'CARRNAME' that will be passed to
 "method add_sort of class cl_salv_sorts
  o_alv-&amp;gt;display_alv( 'CARRNAME' ).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marcelo Ramos&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Nov 2007 14:40:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-sort-using-abap-objects/m-p/3051692#M722529</guid>
      <dc:creator>marcelo_ramos1</dc:creator>
      <dc:date>2007-11-27T14:40:11Z</dc:date>
    </item>
  </channel>
</rss>

