<?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 in alv in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-in-alv/m-p/5312801#M1224887</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Its simple &lt;/P&gt;&lt;P&gt;for field 1 and field 2 &lt;/P&gt;&lt;P&gt;pass sort_up = 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope it helps &lt;/P&gt;&lt;P&gt;bhanu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 05 Mar 2009 12:03:37 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-03-05T12:03:37Z</dc:date>
    <item>
      <title>sorting in alv</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-in-alv/m-p/5312800#M1224886</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;how to sort two alv fields by comparing with the first field..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;field1    field2&lt;/P&gt;&lt;P&gt;1          a&lt;/P&gt;&lt;P&gt;1          a&lt;/P&gt;&lt;P&gt;1          b&lt;/P&gt;&lt;P&gt;2          c&lt;/P&gt;&lt;P&gt;3          c&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i want to dispaly the output like the below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;field1    field2&lt;/P&gt;&lt;P&gt;1           a&lt;/P&gt;&lt;P&gt;             &lt;/P&gt;&lt;P&gt;             b&lt;/P&gt;&lt;P&gt;2           c&lt;/P&gt;&lt;P&gt;3           c&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when i try the below code&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 = 'FIELD1'.&lt;/P&gt;&lt;P&gt;append wa_sort to it_sort.&lt;/P&gt;&lt;P&gt;clear wa_sort.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;wa_sort-spos = 2.&lt;/P&gt;&lt;P&gt;wa_sort-fieldname = 'FIELD2'.&lt;/P&gt;&lt;P&gt;append wa_sort to it_sort.&lt;/P&gt;&lt;P&gt;clear wa_sort.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the output is coming like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;field1    field2&lt;/P&gt;&lt;P&gt;1           a&lt;/P&gt;&lt;P&gt;             &lt;/P&gt;&lt;P&gt;             b&lt;/P&gt;&lt;P&gt;2           c&lt;/P&gt;&lt;P&gt;3                                   --&amp;gt;c is merging for both 2 and 3    &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;pls let me know how to rectify this..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Mar 2009 12:01:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-in-alv/m-p/5312800#M1224886</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-05T12:01:40Z</dc:date>
    </item>
    <item>
      <title>Re: sorting in alv</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-in-alv/m-p/5312801#M1224887</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Its simple &lt;/P&gt;&lt;P&gt;for field 1 and field 2 &lt;/P&gt;&lt;P&gt;pass sort_up = 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope it helps &lt;/P&gt;&lt;P&gt;bhanu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Mar 2009 12:03:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-in-alv/m-p/5312801#M1224887</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-05T12:03:37Z</dc:date>
    </item>
    <item>
      <title>Re: sorting in alv</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-in-alv/m-p/5312802#M1224888</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:-&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
*SORTING
DATA : it_sort TYPE slis_t_sortinfo_alv,
       wa_sort TYPE slis_sortinfo_alv.

*&amp;amp;---------------------------------------------------------------------*
*          SORT W.R.T. FIELD1
*&amp;amp;---------------------------------------------------------------------*
  wa_sort-spos = 1.
  wa_sort-fieldname = '&amp;lt;FIELD1&amp;gt;'.
  wa_sort-tabname = 'ITAB'.
  wa_sort-up = 'X'.
  APPEND wa_sort TO it_sort.
  CLEAR wa_sort.

"now pass this it_sort in REUSE_ALV_GRID_DISPLAY
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Tarun&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Mar 2009 12:07:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-in-alv/m-p/5312802#M1224888</guid>
      <dc:creator>I355602</dc:creator>
      <dc:date>2009-03-05T12:07:45Z</dc:date>
    </item>
    <item>
      <title>Re: sorting in alv</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-in-alv/m-p/5312803#M1224889</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;Instead of declaring the field catalog for sorting you can simply sort your internal table as follows:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SORT &amp;lt;i_tab&amp;gt; BY &amp;lt;field1&amp;gt; ASCENDING &amp;lt;field2&amp;gt; ASCENDING.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: rajan roy on Mar 5, 2009 1:30 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Mar 2009 12:15:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-in-alv/m-p/5312803#M1224889</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-05T12:15:11Z</dc:date>
    </item>
    <item>
      <title>Re: sorting in alv</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-in-alv/m-p/5312804#M1224890</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mallika,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Before passing the table for display ,&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DELETE adjacent duplicates from t_itab comparing all fields.
describe table t_itab lines w_lines.
loop at t_itab.
  w_fld1 = t_itab-fld1.
  w_idx = sy-tabix + 1.
  do w_lines times.
  read table t_itab index w_idx.
  if t_itab-fld1 = w_fld1.
     t_itab-fld1 = space.
    endif.
   add 1 to w_idx.
   if w_idx = w_lines.
   exit.
   endif.
  enddo.
  endloop.

  fs_fcat-fieldname = 'FLD1'.
  append fs_fcat to t_fcat.

    fs_fcat-fieldname = 'FLD2'.
    append fs_fcat to t_fcat.


  fs_sort-spos = 1.
  fs_sort-fieldname = 'FLD1'.
  fs_sort-UP = 'X'.
  append fs_sort to t_sort.
&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;Mdi.Deeba&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Mar 2009 13:26:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-in-alv/m-p/5312804#M1224890</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-05T13:26:40Z</dc:date>
    </item>
  </channel>
</rss>

