<?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 table control in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-in-table-control/m-p/1385686#M187777</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, you can, but you need to code for it.  You need to find what column the users cursor is in when the user clicks the sort button in the screen.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data: cursorfield(10) type c.
GET cursor field cursorfield.





&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This the cursor is in the table control column, CURSORFIELD will be populated with the value 'ITAB-FLD1'.  Here you need to stripp off the ITAB- and just have the FLD1.  Then you can use this in a dynamic sort statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

  data: sort_table(20) type c.
  data: sort_column(20) type c.

  split cursorfield at '-' into sort_table sort_column.

  if sort_table = 'ITAB'.
    sort itab by (sort_column) ascending.
  endif.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&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>Thu, 20 Jul 2006 18:38:12 GMT</pubDate>
    <dc:creator>RichHeilman</dc:creator>
    <dc:date>2006-07-20T18:38:12Z</dc:date>
    <item>
      <title>sorting in table control</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-in-table-control/m-p/1385685#M187776</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;I want to know whether is there a sorting facility  for different columns in a table control of module pool program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have 5 columns in table control .Is there any way that i can sort on whatever column i want.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I mean like we have in alv right. Is it possible in table control too.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If yes please let me know&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Jul 2006 18:31:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-in-table-control/m-p/1385685#M187776</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-07-20T18:31:47Z</dc:date>
    </item>
    <item>
      <title>Re: sorting in table control</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-in-table-control/m-p/1385686#M187777</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, you can, but you need to code for it.  You need to find what column the users cursor is in when the user clicks the sort button in the screen.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data: cursorfield(10) type c.
GET cursor field cursorfield.





&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This the cursor is in the table control column, CURSORFIELD will be populated with the value 'ITAB-FLD1'.  Here you need to stripp off the ITAB- and just have the FLD1.  Then you can use this in a dynamic sort statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

  data: sort_table(20) type c.
  data: sort_column(20) type c.

  split cursorfield at '-' into sort_table sort_column.

  if sort_table = 'ITAB'.
    sort itab by (sort_column) ascending.
  endif.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&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>Thu, 20 Jul 2006 18:38:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-in-table-control/m-p/1385686#M187777</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2006-07-20T18:38:12Z</dc:date>
    </item>
    <item>
      <title>Re: sorting in table control</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-in-table-control/m-p/1385687#M187778</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can also do this when the user highlights a column by clicking the header to find what column to sort by, this is a little more complex.  I'm looking for an example.&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>Thu, 20 Jul 2006 18:44:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-in-table-control/m-p/1385687#M187778</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2006-07-20T18:44:38Z</dc:date>
    </item>
    <item>
      <title>Re: sorting in table control</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-in-table-control/m-p/1385688#M187779</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Swathi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please check demo program &amp;lt;b&amp;gt;DEMO_DYNPRO_TABCONT_LOOP_AT&amp;lt;/b&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this will help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ferry Lianto&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Jul 2006 18:47:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-in-table-control/m-p/1385688#M187779</guid>
      <dc:creator>ferry_lianto</dc:creator>
      <dc:date>2006-07-20T18:47:22Z</dc:date>
    </item>
    <item>
      <title>Re: sorting in table control</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-in-table-control/m-p/1385689#M187780</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, here is the example of the user selecting the column by highlighting the column and clicking a sort button.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the user command.  Here itabcon is the name of your table control.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;


data:
      cursor_table(5) type c,
      cursor_field(10) type c,
      cursor_column(20) type c  ,
       column_name like line of itabcon-cols.

  clear: column_name, cursor_column, cursor_table, cursor_field.
  loop at itabcon-cols into column_name where not selected is initial.
    cursor_column = column_name.
    split cursor_column at '-' into cursor_table cursor_field.
  endloop.
  if cursor_column is initial.
    get cursor field cursor_column.
  endif.

case ok_code.

    when 'ASORT'.

      clear ok_code.
      sort itab stable by (cursor_field) ascending.

endcase.


&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;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Jul 2006 18:50:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-in-table-control/m-p/1385689#M187780</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2006-07-20T18:50:35Z</dc:date>
    </item>
    <item>
      <title>Re: sorting in table control</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-in-table-control/m-p/1385690#M187781</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rich,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This my screEn PBO&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Process before output.&lt;/P&gt;&lt;P&gt;  module status_100.&lt;/P&gt;&lt;P&gt;  module get_data.&lt;/P&gt;&lt;P&gt;  loop at itab with control&lt;/P&gt;&lt;P&gt;               cnt_abc cursor cnt_abc-top_line.&lt;/P&gt;&lt;P&gt;    module display_data.&lt;/P&gt;&lt;P&gt;  endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I DECLARED IN  module get_data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA : CURSORFIELD(10) TYPE C.&lt;/P&gt;&lt;P&gt;GET cursor field cursorfield.&lt;/P&gt;&lt;P&gt;Iam retrieving data from ztable into itab&lt;/P&gt;&lt;P&gt;if sy-ucomm = 'SORT'.&lt;/P&gt;&lt;P&gt;  sort itab by cursorfield. "sorting&lt;/P&gt;&lt;P&gt;else.&lt;/P&gt;&lt;P&gt; sort itab by erdat ertime.&lt;/P&gt;&lt;P&gt; endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IT GIVES ME AN ERROR SAYING&lt;/P&gt;&lt;P&gt;no component exists with name cursor field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please let me know iam wrong anywhere in the process.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Jul 2006 19:00:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-in-table-control/m-p/1385690#M187781</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-07-20T19:00:18Z</dc:date>
    </item>
    <item>
      <title>Re: sorting in table control</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-in-table-control/m-p/1385691#M187782</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;check the syntax:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;GET CURSOR FIELD fldname VALUE fldval.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ex:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: CURSORFIELD(20) TYPE C,CURSOR(10) TYPE C.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;GET CURSOR FIELD CURSORFIELD VALUE CURSOR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Appana&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Jul 2006 19:06:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-in-table-control/m-p/1385691#M187782</guid>
      <dc:creator>Laxmana_Appana_</dc:creator>
      <dc:date>2006-07-20T19:06:08Z</dc:date>
    </item>
    <item>
      <title>Re: sorting in table control</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-in-table-control/m-p/1385692#M187783</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please check the samples above closer, the CUSORFIELD needs to be wrapped with parenthesis and this should be done in the PAI when the user clicks the sort button.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;  sort itab stable by &amp;lt;b&amp;gt;(cursor_field)&amp;lt;/b&amp;gt; ascending.&lt;/CODE&gt;&lt;/PRE&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>Thu, 20 Jul 2006 19:10:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-in-table-control/m-p/1385692#M187783</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2006-07-20T19:10:42Z</dc:date>
    </item>
    <item>
      <title>Re: sorting in table control</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-in-table-control/m-p/1385693#M187784</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rich,&lt;/P&gt;&lt;P&gt;I have fixed the problem with the help of your code.&lt;/P&gt;&lt;P&gt;I have awarded full points.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a nice day&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Jul 2006 20:29:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-in-table-control/m-p/1385693#M187784</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-07-20T20:29:37Z</dc:date>
    </item>
    <item>
      <title>Re: sorting in table control</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-in-table-control/m-p/1385694#M187785</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rich Heilman.,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; It's Working Fine For Single Column Sorting. But I Need To Sort The Table By Multiple Column As The User Selected Order. Please Guide Me How To Do?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Mar 2012 08:47:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-in-table-control/m-p/1385694#M187785</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-03-21T08:47:48Z</dc:date>
    </item>
  </channel>
</rss>

