<?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: ALV Buttons in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-buttons/m-p/3458002#M830839</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Sandeep,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your code help me. I get the Standard ALV buttons in my program.&lt;/P&gt;&lt;P&gt;But I want the Standard ALV buttons as well as my own Customized buttons simultaneouly which I cant get till now..&lt;/P&gt;&lt;P&gt;Can u pls help me.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 14 Feb 2008 08:08:44 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-02-14T08:08:44Z</dc:date>
    <item>
      <title>ALV Buttons</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-buttons/m-p/3457997#M830834</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How can you add your own button on the application toolbar in ALV? Tell each step.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Feb 2008 11:20:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-buttons/m-p/3457997#M830834</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-13T11:20:54Z</dc:date>
    </item>
    <item>
      <title>Re: ALV Buttons</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-buttons/m-p/3457998#M830835</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In the program which calls ALV using REUSE_ALV_LIST_DISPLAY, &lt;/P&gt;&lt;P&gt;I have to add a new button. &lt;/P&gt;&lt;P&gt;I saw the demo program BCALV_GRID_08, which is written using ABAP-Controls. &lt;/P&gt;&lt;P&gt;In that example, the button is added using TOOLBAR event of cl_gui_alv_grid. &lt;/P&gt;&lt;P&gt;Could you help me to implement the same logic using REUSE_ALV_LIST_DISPLAY parameters. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you should copy the 'STANDARD' GUI status from program SAPLKKBL using transaction SE90 &lt;DEL&gt;&amp;gt;Programming SubObjects&lt;/DEL&gt;&amp;gt; Gui Status. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Execute this transaction to get to next screen. select status using checkbox. click on GUI Status --&amp;gt; Copy. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Enter your Z program name and the name you what for this status - you can keep it as 'STANDARD' to be simple. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then you can edit the new status to add or delete buttons. This will also bring in the standard SAP ALV functionality such as sorting/subtotaling etc... &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When you call 'REUSE_ALV_GRID_DISPLAY' make sure you pass it the new status name. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;an example of one of mine: &lt;/P&gt;&lt;P&gt;call function 'REUSE_ALV_GRID_DISPLAY' &lt;/P&gt;&lt;P&gt;EXPORTING &lt;/P&gt;&lt;P&gt;i_callback_program = 'ZSDBOLST_REPORT' &lt;/P&gt;&lt;P&gt;i_callback_pf_status_set = 'STANDARD' &amp;lt;----&lt;/P&gt;&lt;HR originaltext="----" /&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;i_callback_user_command = 'USER_COMMAND' &lt;/P&gt;&lt;P&gt;i_structure_name = 'I_BOLACT' &lt;/P&gt;&lt;P&gt;i_grid_title = 'BOL Action Report'(031) &lt;/P&gt;&lt;P&gt;is_layout = gs_layout &lt;/P&gt;&lt;P&gt;it_fieldcat = gt_fieldcat[] &lt;/P&gt;&lt;P&gt;i_save = 'A' &lt;/P&gt;&lt;P&gt;is_variant = v_variant &lt;/P&gt;&lt;P&gt;TABLES &lt;/P&gt;&lt;P&gt;t_outtab = i_bolact &lt;/P&gt;&lt;P&gt;EXCEPTIONS &lt;/P&gt;&lt;P&gt;program_error = 1 &lt;/P&gt;&lt;P&gt;others = 2. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I just tried the same procedure ,but my entire application toolbar disappeared and a lock icon appears next to the application toolbar in my copied pf-status. &lt;/P&gt;&lt;P&gt;Could you advice what might have gone wrong ? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As identified with the FM's help you can do the following. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1). Using SE80 (I think) you can copy a GUI status from one program to another. It mentions which one in the FM's help. &lt;/P&gt;&lt;P&gt;2). Create a form named like so: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Form Set_pf_status &lt;/P&gt;&lt;P&gt;Notes: Called by FM REUSE_ALV_GRID_DISPLAY &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM set_pf_status USING rt_extab TYPE slis_t_extab. &lt;/P&gt;&lt;P&gt;SET PF-STATUS 'ZSTANDARD'. &lt;/P&gt;&lt;P&gt;ENDFORM. "Set_pf_status &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the above case the GUI status copied was named ZSTANDARD and adjusted accordingly, adding and removing the desired buttons. A button was added called '%DELETE'. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3). Create the following report: &lt;/P&gt;&lt;P&gt;Code: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Form User_command &lt;/P&gt;&lt;P&gt;Notes: Called by FM REUSE_ALV_GRID_DISPLAY &lt;/P&gt;&lt;P&gt;Detects whether the icon/button for &lt;/P&gt;&lt;P&gt;'Return Tag Deletion' has been pressed. If it has then &lt;/P&gt;&lt;P&gt;detect whether any rows have been highlighted and then &lt;/P&gt;&lt;P&gt;set the delete flag. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM user_command USING r_ucomm LIKE sy-ucomm &lt;/P&gt;&lt;P&gt;rs_selfield TYPE slis_selfield. &lt;/P&gt;&lt;P&gt;DATA: li_count TYPE I. &lt;/P&gt;&lt;P&gt;IF r_ucomm EQ '%DELETE'. &lt;/P&gt;&lt;P&gt;LOOP AT %g00 WHERE mark EQ 'X'. &lt;/P&gt;&lt;P&gt;ADD 1 TO li_count. &lt;/P&gt;&lt;P&gt;ENDLOOP. &lt;/P&gt;&lt;P&gt;IF li_count GT 0. &lt;/P&gt;&lt;P&gt;gc_delete_flag = 'X'. &lt;/P&gt;&lt;P&gt;r_ucomm = '&amp;amp;F03'. "Back arraow &lt;/P&gt;&lt;P&gt;ELSE. &lt;/P&gt;&lt;P&gt;MESSAGE W000 WITH 'Please highlight the rows to be deleted!'. &lt;/P&gt;&lt;P&gt;ENDIF. &lt;/P&gt;&lt;P&gt;ENDIF. &lt;/P&gt;&lt;P&gt;ENDFORM. "User_command &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As I've added an extra button to indicate which records should be deleted I need to identify a form to be called to process when this button is chosen. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then when you call the ALV function you to specify the following extra details: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code: &lt;/P&gt;&lt;P&gt;call function 'REUSE_ALV_GRID_DISPLAY' &lt;/P&gt;&lt;P&gt;exporting i_callback_program = gc_repid &lt;/P&gt;&lt;P&gt;I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS' &lt;/P&gt;&lt;P&gt;I_CALLBACK_USER_COMMAND = 'USER_COMMAND' &lt;/P&gt;&lt;P&gt;i_grid_title = lc_grid_title &lt;/P&gt;&lt;P&gt;is_layout = lc_layout &lt;/P&gt;&lt;P&gt;it_fieldcat = gt_fieldcat &lt;/P&gt;&lt;P&gt;it_sort = sort &lt;/P&gt;&lt;P&gt;i_save = l_save &lt;/P&gt;&lt;P&gt;is_reprep_id = l_bbs_id &lt;/P&gt;&lt;P&gt;is_variant = l_variant &lt;/P&gt;&lt;P&gt;tables t_outtab = %g00 &lt;/P&gt;&lt;P&gt;exceptions program_error = 1 &lt;/P&gt;&lt;P&gt;others = 2. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The parameters in capitals are the extra ones that need to be added.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward Points if useful&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Feb 2008 11:41:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-buttons/m-p/3457998#M830835</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-13T11:41:52Z</dc:date>
    </item>
    <item>
      <title>Re: ALV Buttons</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-buttons/m-p/3457999#M830836</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;1) Copy existing gui or creat your own (better to copy for standart buttons).&lt;/P&gt;&lt;P&gt;2) In se80 double open gui status and open your status.&lt;/P&gt;&lt;P&gt;3) Open application tool bar and enter a name for your button in free cell&lt;/P&gt;&lt;P&gt;4) Choose static text&lt;/P&gt;&lt;P&gt;5)Enter texts and choose an icon for your button.&lt;/P&gt;&lt;P&gt;6)Assign your button&lt;/P&gt;&lt;P&gt;7) Activate gui status.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt; in your program check sy-subrc for code entered in (3) (upper case)&lt;/P&gt;&lt;P&gt;9) enter logic in program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Yossi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Feb 2008 13:25:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-buttons/m-p/3457999#M830836</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-13T13:25:44Z</dc:date>
    </item>
    <item>
      <title>Re: ALV Buttons</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-buttons/m-p/3458000#M830837</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi sulakshana,&lt;/P&gt;&lt;P&gt;here are the steps..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) OPEN SE41&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) TYPE IN YOUR PROGRAM NAME FOR WHICH YOU NEED ALV MENU&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3) on the application tolbar you would see a button named 'STATUS', click it&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4) now it would say copy status FROM AND TO....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;type: &lt;/P&gt;&lt;P&gt;FROM:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROGRAM: SAPLSLVC_FULLSCREEN&lt;/P&gt;&lt;P&gt;STATUS: STANDARD_FULLSCREEN&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TO&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROGRAM:  TYPE YOuR PROGRAM NAME&lt;/P&gt;&lt;P&gt;STATUS : TYPE YOUR CUSTOM MENU NAME&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;5) PRESS COPY..and again till it says a message 'COPIED SUCCESSFULLY&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;6)in you ALV PROGRAM IN EVEN SET_PF_STATUS, &lt;/P&gt;&lt;P&gt;TYPE THIS ALV STATUS AND DOUBLE CLICK UR STATUS NAME&lt;/P&gt;&lt;P&gt;AND THEN YOU WILL HAVE YOUR ALV STANDARD MENU..AND&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;YOU CAN HAVE YOUR BUTTON ON IT, BY MAKING YOU OWN COMMAND SAY '&amp;amp;MAT'   name it as MAterial info&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;6) ACTIVATE IT&lt;/P&gt;&lt;P&gt;AND YOUR ALV MENU IS MADE&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;reward points if helpful&lt;/P&gt;&lt;P&gt;Rohan malik&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Feb 2008 14:30:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-buttons/m-p/3458000#M830837</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-13T14:30:32Z</dc:date>
    </item>
    <item>
      <title>Re: ALV Buttons</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-buttons/m-p/3458001#M830838</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi...&lt;/P&gt;&lt;P&gt;You can go thru this code,...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;i_callback_program = ws_repid&lt;/P&gt;&lt;P&gt;i_callback_pf_status_set = 'GUI_STAT'&lt;/P&gt;&lt;P&gt;i_callback_user_command = 'STAT'&lt;/P&gt;&lt;P&gt;is_layout = gs_layout&lt;/P&gt;&lt;P&gt;it_fieldcat = i_fieldcat[]&lt;/P&gt;&lt;P&gt;TABLES&lt;/P&gt;&lt;P&gt;t_outtab = i_zaw_pol_plan.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM gui_stat USING rt_extab TYPE slis_t_extab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SET PF-STATUS 'STANDARD' EXCLUDING rt_extab.&lt;/P&gt;&lt;P&gt;SET TITLEBAR text-005.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Double click on 'STANDARD' and set the status.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here you will loose the standard ALV toolbar.&lt;/P&gt;&lt;P&gt;If you want to get STANDARD ALV tool bar...you need to do this navigations.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SE80 -&amp;gt;give Function Group as SALV -&amp;gt; right click on GUI status -&amp;gt; copy STANDARD menu to your program -&amp;gt;go to SE41 -&amp;gt; Activate the menu -&amp;gt; now you will get the menu in your program -&amp;gt; if you want to add any buttons or want to do any changes in the menu, you can do using SE41-&amp;gt; save and activate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;sandeep.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Feb 2008 14:34:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-buttons/m-p/3458001#M830838</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-13T14:34:05Z</dc:date>
    </item>
    <item>
      <title>Re: ALV Buttons</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-buttons/m-p/3458002#M830839</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Sandeep,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your code help me. I get the Standard ALV buttons in my program.&lt;/P&gt;&lt;P&gt;But I want the Standard ALV buttons as well as my own Customized buttons simultaneouly which I cant get till now..&lt;/P&gt;&lt;P&gt;Can u pls help me.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Feb 2008 08:08:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-buttons/m-p/3458002#M830839</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-14T08:08:44Z</dc:date>
    </item>
    <item>
      <title>Re: ALV Buttons</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-buttons/m-p/3458003#M830840</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh dear me -- You guys make this stuff FAR TOO COMPLICATED.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FIRST FORGET the SLIS / FM method of ALV. It's OBSOLETE COMPLICATED and not easy to program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use CL_SALV_table* for simple  non editable grids or cl_gui_alv_grid for more complicated stuff.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's a complete SIMPLE OO program which adds a user function to the toolbar and when you press it  the  routine calls your on_user_command function.&lt;/P&gt;&lt;P&gt;This grid is also editable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've made a simple application here rather than that stupid airline one - -of all the applications you can use SAP for Airline reservation isn't likely to be one of them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The double click and hotspot functions are active so you can do stuff when you double click a cell such as display sales order etc etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Before you start create a standard screen 100 with just a custom control on it called CCONTAINER1 and a standard SE41 status  000 with just BACK, EXIT and CANCEL standard functions..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the screen logic just needs &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

process before output.
 module status_0100.
*
process after input.
 module user_command_0100.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Once you get used to ALV OO you don't even need a screen anymore as you can build this in anyway. For non editable grids you can also use the new salv table class but this has fairly limited functionality.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;anyway here's the rest of the code. There's break-points in it as well to show the relevant processes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
PROGRAM zzz_simple_editable_grid.
include &amp;lt;icon&amp;gt;.
CLASS LCL_EVENT_HANDLER DEFINITION .
  PUBLIC SECTION .
    METHODS:
**Hot spot Handler
    HANDLE_HOTSPOT_CLICK FOR EVENT HOTSPOT_CLICK OF CL_GUI_ALV_GRID
                      IMPORTING E_ROW_ID E_COLUMN_ID ES_ROW_NO,
**Double Click Handler
    HANDLE_DOUBLE_CLICK FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
                                    IMPORTING E_ROW E_COLUMN ES_ROW_NO,
** Toolbar handler.
 handle_toolbar
        FOR EVENT toolbar OF cl_gui_alv_grid
            IMPORTING e_object e_interactive,
* button press
    handle_user_command
        FOR EVENT user_command OF cl_gui_alv_grid
            IMPORTING e_ucomm.

ENDCLASS.                    "lcl_event_handler DEFINITION
CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
*Handle Hotspot Click
  METHOD HANDLE_HOTSPOT_CLICK .
    break-point 1.
  ENDMETHOD.                    "lcl_event_handler

*Handle Double Click
  METHOD  HANDLE_DOUBLE_CLICK.
break-point 2.
  ENDMETHOD.

  METHOD handle_toolbar.
  DATA: ls_toolbar  TYPE stb_button.
break-point 1.
* append a separator to normal toolbar
    CLEAR ls_toolbar.
    MOVE 3 TO ls_toolbar-butn_type.
    APPEND ls_toolbar TO e_object-&amp;gt;mt_toolbar.
* append an icon for your function
    CLEAR ls_toolbar.
    MOVE 'FUNC' TO ls_toolbar-function.
    MOVE icon_railway TO ls_toolbar-icon.
    MOVE 'Your Function' TO ls_toolbar-quickinfo.
    MOVE 'Your user function' TO ls_toolbar-text.
    MOVE ' ' TO ls_toolbar-disabled.
    APPEND ls_toolbar TO e_object-&amp;gt;mt_toolbar.

  ENDMETHOD.
  method handle_user_command.
  break-point 1.
  case e_ucomm.
  when 'FUNC'.    "Your button
* Perform what you need to do.
  when others.
  endcase.
  endmethod.

  endclass.

* Define any structure
TYPES:  BEGIN OF s_elements,
  vbeln   TYPE vapma-vbeln,
  posnr   TYPE vapma-posnr,
  matnr   TYPE vapma-matnr,
  kunnr   TYPE vapma-kunnr,
  werks   TYPE vapma-werks,
  vkorg   TYPE vapma-vkorg,
  vkbur   TYPE vapma-vkbur,
  status  TYPE c,

END OF  s_elements.

* end of your structure

DATA lr_rtti_struc TYPE REF TO cl_abap_structdescr .
DATA:
    zog                     LIKE LINE OF lr_rtti_struc-&amp;gt;components .
DATA:
  zogt                    LIKE TABLE OF zog,
wa_it_fldcat TYPE lvc_s_fcat,
it_fldcat TYPE lvc_t_fcat ,
dy_line            TYPE REF TO data,
dy_table           TYPE REF TO data.


DATA:  dref               TYPE REF TO data.
FIELD-SYMBOLS: &amp;lt;fs&amp;gt; TYPE ANY,
   &amp;lt;dyn_table&amp;gt;    TYPE  STANDARD TABLE,
   &amp;lt;dyn_wa&amp;gt;.

DATA grid_container1 TYPE REF TO cl_gui_custom_container .
DATA: G_HANDLER TYPE REF TO LCL_EVENT_HANDLER. "handler

DATA grid1 TYPE REF TO cl_gui_alv_grid .
DATA: ok_code TYPE sy-ucomm.
DATA: struct_grid_lset TYPE lvc_s_layo.
start-of-selection.
*now I want to build a field catalog
* First get your data structure into a field symbol

CREATE DATA dref TYPE s_elements.
ASSIGN dref-&amp;gt;* TO &amp;lt;fs&amp;gt;.

lr_rtti_struc ?= cl_abap_structdescr=&amp;gt;describe_by_data( &amp;lt;fs&amp;gt; ).

* Now get the structure details into a table.
* table zogt[] contains the structure details
* From which we can build the field catalog

zogt[]  = lr_rtti_struc-&amp;gt;components.
LOOP AT zogt INTO zog.
  CLEAR wa_it_fldcat.
  wa_it_fldcat-fieldname = zog-name .
  wa_it_fldcat-datatype = zog-type_kind.
  wa_it_fldcat-inttype = zog-type_kind.
  wa_it_fldcat-intlen = zog-length.
  wa_it_fldcat-decimals = zog-decimals.
  wa_it_fldcat-coltext = zog-name.
  wa_it_fldcat-lowercase = 'X'.
  if wa_it_fldcat-fieldname = 'VBELN'.
  wa_it_fldcat-hotspot = 'X'.
  ENDIF.
  APPEND wa_it_fldcat TO it_fldcat.

ENDLOOP.
*
* You can perform any modifications / additions to your field catalog
* here such as your own column names etc.

* Now using the field catalog created above we can
* build a dynamic table
* and populate it

* First build the dynamic table
* the table will contain entries for
* our structure defined at the start of the program

CALL METHOD cl_alv_table_create=&amp;gt;create_dynamic_table
       EXPORTING
            it_fieldcatalog = it_fldcat
       IMPORTING
            ep_table = dy_table.


ASSIGN dy_table-&amp;gt;* TO &amp;lt;dyn_table&amp;gt;.
CREATE DATA dy_line LIKE LINE OF &amp;lt;dyn_table&amp;gt;.
ASSIGN dy_line-&amp;gt;* TO &amp;lt;dyn_wa&amp;gt;.

* Now fill our table with data

SELECT vbeln posnr matnr kunnr werks vkorg vkbur
       UP TO 200 ROWS
       FROM vapma
       INTO  CORRESPONDING FIELDS OF TABLE &amp;lt;dyn_table&amp;gt;.

* Call the screen to display the grid
CALL SCREEN 100.

* PBO module

MODULE status_0100 OUTPUT.
data: off type int4.
break-point 1.
if sy-batch = 'X'.
 CALL METHOD cl_gui_alv_grid=&amp;gt;offline
RECEIVING
e_offline = off.
endif.

if sy-batch = 'X'.
 IF ( off IS INITIAL ).
    CREATE OBJECT grid_container1
            EXPORTING
               container_name = 'CCONTAINER1'.
    CREATE OBJECT  grid1
       EXPORTING
          i_parent = grid_container1.
ENDIF.
endif.
if sy-batch ne 'X'.

   IF grid_container1 IS INITIAL.
     CREATE OBJECT grid_container1
             EXPORTING
                container_name = 'CCONTAINER1'.
  endif.
    CREATE OBJECT  grid1
       EXPORTING
          i_parent = grid_container1.
   if sy-batch ne 'X'.
    struct_grid_lset-edit = 'X'.    "To enable editing in ALV
  endif.
  endif.

  CREATE OBJECT G_HANDLER.
  SET HANDLER G_HANDLER-&amp;gt;HANDLE_DOUBLE_CLICK FOR Grid1.
  SET HANDLER G_HANDLER-&amp;gt;HANDLE_HOTSPOT_CLICK FOR Grid1.
  set handler g_handler-&amp;gt;handle_toolbar for grid1.
  set handler g_handler-&amp;gt;handle_user_command for grid1.
   call method grid1-&amp;gt;register_edit_event
        exporting
           i_event_id = cl_gui_alv_grid=&amp;gt;mc_evt_enter.


    CALL METHOD grid1-&amp;gt;set_table_for_first_display
      EXPORTING is_layout =  struct_grid_lset
      CHANGING
                 it_outtab       = &amp;lt;dyn_table&amp;gt;
                 it_fieldcatalog = it_fldcat.



  SET PF-STATUS '001'.
  SET TITLEBAR '000'.

ENDMODULE.

* PAI module

MODULE user_command_0100 INPUT.
  CASE sy-ucomm.
    WHEN 'BACK'.
      LEAVE PROGRAM.
    WHEN 'EXIT'.
      LEAVE PROGRAM.
    WHEN 'RETURN'.
      LEAVE PROGRAM.
    WHEN OTHERS.
  ENDCASE.
ENDMODULE.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cheers&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and please no more old SLIS stuff.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;jimbo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Feb 2008 08:44:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-buttons/m-p/3458003#M830840</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-14T08:44:32Z</dc:date>
    </item>
  </channel>
</rss>

