<?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: Reg : GET_SELECTED_COLUMNS in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/reg-get-selected-columns/m-p/2759985#M642491</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;u try this &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First thing is that you need a local class as your event handler, copy and paste this code. Here we are using the name ALV_GRID for your alv object&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: alv_grid       type ref to cl_gui_alv_grid.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;***********************************************************************&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      CLASS lcl_event_receiver DEFINITION&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;***********************************************************************&lt;/P&gt;&lt;P&gt;class lcl_event_receiver definition.&lt;/P&gt;&lt;P&gt;  public section.&lt;/P&gt;&lt;P&gt;    methods handle_user_command&lt;/P&gt;&lt;P&gt;      for event before_user_command of cl_gui_alv_grid&lt;/P&gt;&lt;P&gt;      importing e_ucomm.&lt;/P&gt;&lt;P&gt;  private section.&lt;/P&gt;&lt;P&gt;endclass.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;***********************************************************************&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      CLASS lCL_EVENT_RECEIVER IMPLEMENTATION&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;***********************************************************************&lt;/P&gt;&lt;P&gt;class lcl_event_receiver implementation.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;  method handle_user_command.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;    data: icols type lvc_t_col,&lt;/P&gt;&lt;P&gt;          xcols like line of icols.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Get the currently selected column&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    call method alv_grid-&amp;gt;get_selected_columns&lt;/P&gt;&lt;P&gt;       importing&lt;/P&gt;&lt;P&gt;         et_index_columns = icols.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;    read table icols into xcols index 1.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;If the selected column is not one that should be sorted&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    check xcols-fieldname = 'MATNR'.    "&amp;lt;-- Whatever columns that you don't want to allow sorting on.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Now check the function code, if sort ascending or descending, then give message&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    check e_ucomm = cl_gui_alv_grid=&amp;gt;mc_fc_sort_asc&lt;/P&gt;&lt;P&gt;      or  e_ucomm =  cl_gui_alv_grid=&amp;gt;mc_fc_sort_dsc.&lt;/P&gt;&lt;P&gt;    message i001(00) with 'Can not sort on this column'.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Now set the UCOMM as if the user didn't click anything.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    call method alv_grid-&amp;gt;set_user_command( space ).&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;  endmethod.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;endclass.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;data: event_receiver type ref to lcl_event_receiver.&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;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, you will need to set the event hanlder after calling the SET_TABLE_FOR_FIRST_DISPLAY.&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;&lt;P&gt;  call method alv_grid-&amp;gt;set_table_for_first_display&lt;/P&gt;&lt;P&gt;      changing&lt;/P&gt;&lt;P&gt;           it_outtab       = i_alv[]&lt;/P&gt;&lt;P&gt;           it_fieldcatalog = ifc[].&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; Set the handler for ALV grid&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  create object event_receiver.&lt;/P&gt;&lt;P&gt;  set handler event_receiver-&amp;gt;handle_user_command for alv_grid.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 30 Aug 2007 06:22:27 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-08-30T06:22:27Z</dc:date>
    <item>
      <title>Reg : GET_SELECTED_COLUMNS</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reg-get-selected-columns/m-p/2759983#M642489</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Friends,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have requirement where the user can select columns on ALV-display and then clicks a custom button,now i need to capture which columns were selected by the user and using this info i display another ALV in another screen.Till here its fine.&lt;/P&gt;&lt;P&gt;(I am capturing the columns user  using method  "GET_SELECTED_COLUMNS".)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But now when i am hitting back button on the 2nd ALV display screen and going back to initial display.here when i selecet some other combination of columns...and hit the custom button..this time the method is not giving the selected colums.The method is failing the second time.I have to litreally run the whole program again from the TCODE for it to strt working again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need help this is urgent.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and Regards,&lt;/P&gt;&lt;P&gt;Venkat.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Aug 2007 17:22:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reg-get-selected-columns/m-p/2759983#M642489</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-29T17:22:26Z</dc:date>
    </item>
    <item>
      <title>Re: Reg : GET_SELECTED_COLUMNS</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reg-get-selected-columns/m-p/2759984#M642490</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;Please find a link.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_message" href="https://community.sap.com/" __jive_macro_name="message" modifiedtitle="true" __default_attr="3607490"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;please look into Rich's reply,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;aRs&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Aug 2007 20:05:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reg-get-selected-columns/m-p/2759984#M642490</guid>
      <dc:creator>former_member194669</dc:creator>
      <dc:date>2007-08-29T20:05:17Z</dc:date>
    </item>
    <item>
      <title>Re: Reg : GET_SELECTED_COLUMNS</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reg-get-selected-columns/m-p/2759985#M642491</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;u try this &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First thing is that you need a local class as your event handler, copy and paste this code. Here we are using the name ALV_GRID for your alv object&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: alv_grid       type ref to cl_gui_alv_grid.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;***********************************************************************&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      CLASS lcl_event_receiver DEFINITION&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;***********************************************************************&lt;/P&gt;&lt;P&gt;class lcl_event_receiver definition.&lt;/P&gt;&lt;P&gt;  public section.&lt;/P&gt;&lt;P&gt;    methods handle_user_command&lt;/P&gt;&lt;P&gt;      for event before_user_command of cl_gui_alv_grid&lt;/P&gt;&lt;P&gt;      importing e_ucomm.&lt;/P&gt;&lt;P&gt;  private section.&lt;/P&gt;&lt;P&gt;endclass.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;***********************************************************************&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      CLASS lCL_EVENT_RECEIVER IMPLEMENTATION&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;***********************************************************************&lt;/P&gt;&lt;P&gt;class lcl_event_receiver implementation.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;  method handle_user_command.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;    data: icols type lvc_t_col,&lt;/P&gt;&lt;P&gt;          xcols like line of icols.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Get the currently selected column&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    call method alv_grid-&amp;gt;get_selected_columns&lt;/P&gt;&lt;P&gt;       importing&lt;/P&gt;&lt;P&gt;         et_index_columns = icols.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;    read table icols into xcols index 1.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;If the selected column is not one that should be sorted&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    check xcols-fieldname = 'MATNR'.    "&amp;lt;-- Whatever columns that you don't want to allow sorting on.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Now check the function code, if sort ascending or descending, then give message&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    check e_ucomm = cl_gui_alv_grid=&amp;gt;mc_fc_sort_asc&lt;/P&gt;&lt;P&gt;      or  e_ucomm =  cl_gui_alv_grid=&amp;gt;mc_fc_sort_dsc.&lt;/P&gt;&lt;P&gt;    message i001(00) with 'Can not sort on this column'.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Now set the UCOMM as if the user didn't click anything.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    call method alv_grid-&amp;gt;set_user_command( space ).&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;  endmethod.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;endclass.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;data: event_receiver type ref to lcl_event_receiver.&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;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, you will need to set the event hanlder after calling the SET_TABLE_FOR_FIRST_DISPLAY.&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;&lt;P&gt;  call method alv_grid-&amp;gt;set_table_for_first_display&lt;/P&gt;&lt;P&gt;      changing&lt;/P&gt;&lt;P&gt;           it_outtab       = i_alv[]&lt;/P&gt;&lt;P&gt;           it_fieldcatalog = ifc[].&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; Set the handler for ALV grid&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  create object event_receiver.&lt;/P&gt;&lt;P&gt;  set handler event_receiver-&amp;gt;handle_user_command for alv_grid.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Aug 2007 06:22:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reg-get-selected-columns/m-p/2759985#M642491</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-30T06:22:27Z</dc:date>
    </item>
  </channel>
</rss>

