<?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: CL_SALV_TABLE Create Button Group in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/cl-salv-table-create-button-group/m-p/4670043#M1098476</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Bert,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Caution: I don't think the same screen container can be used for the menu button (cl_gui_alv_grid) and the ALV-OM output (cl_salv_table).  Two separate containers could be used on screen 100, one for the menu button and one for the ALV-OM output, but I don't think that is an ideal solution.  I'll keep trying, but for now have a look at my original reply.  Maybe you or someone else out there can figure out another way.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;This can indeed be done&lt;/U&gt;&lt;/STRONG&gt;.  To demonstrate, I created a skeleton program with just one custom button (with two menu items attached to it).  As far as I can tell, this will only work for the ALV-OM grid option and not for the ALV-OM full screen option.  Maybe the fullscreen option could be a challenge for someone else reading this reply.  &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I looked in programs BCALV_GRID_08 and SALV_TEST_FUNCTIONS and sort of morphed together the two concepts.  Here are the steps to recreate my example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Step 1:&lt;/STRONG&gt; Create a new program (NOTE: In order to make the code as simple as possible for this forum reply, I removed the lines of code that actually output the SPLFI data.  I figured seeing some test data would not be important for understanding the menu button in an ALV-OM.)&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
REPORT  zjrg_alvom_demo_menu_button.

*----------------------------------------------------------------------*
*       CLASS lcl_gui_alv_grid DEFINITION
*----------------------------------------------------------------------*
CLASS lcl_gui_alv_grid DEFINITION INHERITING FROM cl_gui_alv_grid.
  PUBLIC SECTION.
    METHODS: set_toolbar_buttons_grid IMPORTING toolbar_table TYPE ttb_button.
ENDCLASS.                    "lcl_gui_alv_grid DEFINITION

* Global Data
DATA: ispfli        TYPE TABLE OF spfli,
      gr_table      TYPE REF TO cl_salv_table,
      gr_events     TYPE REF TO cl_salv_events_table,
      gr_alv_grid   TYPE REF TO lcl_gui_alv_grid,
      gr_container  TYPE REF TO cl_gui_custom_container,
      ok_code       TYPE syucomm.

*----------------------------------------------------------------------*
*       CLASS lcl_gui_alv_grid IMPLEMENTATION
*----------------------------------------------------------------------*
CLASS lcl_gui_alv_grid IMPLEMENTATION.

  METHOD set_toolbar_buttons_grid.
    CALL METHOD me-&amp;gt;set_toolbar_buttons
      EXPORTING
        toolbar_table = toolbar_table.
  ENDMETHOD.                    "set_toolbar_buttons_grid

ENDCLASS.                    "lcl_gui_alv_grid IMPLEMENTATION

*----------------------------------------------------------------------*
*       CLASS lcl_handle_events DEFINITION
*----------------------------------------------------------------------*
CLASS lcl_handle_events DEFINITION.
  PUBLIC SECTION.
    METHODS:
      handle_menu_button
        FOR EVENT menu_button OF cl_gui_alv_grid
            IMPORTING e_object e_ucomm,

      handle_menu_command
        FOR EVENT user_command OF cl_gui_alv_grid
            IMPORTING e_ucomm.

ENDCLASS.                    "lcl_handle_events DEFINITION

DATA: event_handler TYPE REF TO lcl_handle_events.

START-OF-SELECTION.

  SELECT * FROM spfli INTO TABLE ispfli.
  IF ispfli[] IS INITIAL.
    MESSAGE 'Nothing selected' TYPE 'I'.
    EXIT.
  ENDIF.

  IF cl_salv_table=&amp;gt;is_offline( ) EQ if_salv_c_bool_sap=&amp;gt;false.
    CREATE OBJECT gr_container
      EXPORTING
        container_name = 'CONTAINER'.
  ENDIF.

  TRY.
      cl_salv_table=&amp;gt;factory(
        EXPORTING
          r_container    = gr_container
          container_name = 'CONTAINER'
        IMPORTING
          r_salv_table   = gr_table
        CHANGING
          t_table        = ispfli ).
    CATCH cx_salv_msg.
  ENDTRY.

  CREATE OBJECT gr_alv_grid EXPORTING i_parent = gr_container.

  gr_events = gr_table-&amp;gt;get_event( ).

  CREATE OBJECT event_handler.

  SET HANDLER: event_handler-&amp;gt;handle_menu_button  FOR gr_alv_grid,
               event_handler-&amp;gt;handle_menu_command FOR gr_alv_grid.

* Display the ALV-OM Grid
  CALL SCREEN 100.

*----------------------------------------------------------------------*
*       CLASS lcl_handle_events IMPLEMENTATION
*----------------------------------------------------------------------*
CLASS lcl_handle_events IMPLEMENTATION.

  METHOD handle_menu_button.
    e_object-&amp;gt;add_function( EXPORTING fcode = 'CANC'
                                      text  = 'Cancel').

    e_object-&amp;gt;add_function( EXPORTING fcode = 'EXIT'
                                      text  = 'Exit').

  ENDMETHOD.                    "handle_menu_button

  METHOD handle_menu_command.
    CASE e_ucomm.
      WHEN 'EXIT'.
        MESSAGE 'Exit menu button option.' TYPE 'I'.
        LEAVE TO SCREEN 0.
      WHEN 'CANC'.
        MESSAGE 'Cacnel menu button option.' TYPE 'I'.
    ENDCASE.
  ENDMETHOD.                    "handle_menu_command

ENDCLASS.                    "lcl_handle_events IMPLEMENTATION
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Module  STATUS_0100  OUTPUT
*&amp;amp;---------------------------------------------------------------------*
MODULE status_0100 OUTPUT.

  DATA: it_toolbar TYPE ttb_button.
  FIELD-SYMBOLS: &amp;lt;fs_toolbar&amp;gt; TYPE stb_button.

  APPEND INITIAL LINE TO it_toolbar ASSIGNING &amp;lt;fs_toolbar&amp;gt;.
  &amp;lt;fs_toolbar&amp;gt;-function = 'MENUB'.
  &amp;lt;fs_toolbar&amp;gt;-butn_type = '1'.
  &amp;lt;fs_toolbar&amp;gt;-text = 'Menu test'.

  gr_alv_grid-&amp;gt;set_toolbar_buttons_grid( it_toolbar ).

  gr_table-&amp;gt;display( ).

ENDMODULE.                 " STATUS_0100  OUTPUT&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Step 2:&lt;/STRONG&gt; Create screen 100 for this program with a single custom control called CONTAINER and the following flow logic:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
process before output.
  module status_0100.
*
process after input.
*  
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Activate everything and run the program.  You should see a single custom button for an empty ALV-OM Grid.  This button has two menu items Cancel, and Exit.  Hopefully, this example will give you an idea of how to use this concept in your own development.  &lt;STRONG&gt;You can now use the normal ALV-OM methods to design the rest of your ALV grid output.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Jamie&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: James Gaddis on Oct 27, 2008 5:11 PM  - Did not need code for event handle_toolbar, so I removed it from the program sample.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: James Gaddis on Oct 28, 2008 2:28 PM - Upon further review....  read first paragraph.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 27 Oct 2008 20:49:27 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-10-27T20:49:27Z</dc:date>
    <item>
      <title>CL_SALV_TABLE Create Button Group</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/cl-salv-table-create-button-group/m-p/4670042#M1098475</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;I know how to create a button in an ALV list based on cl_salv_table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The buttons created however are single buttons. I'm trying to create a button which can be expanded like the standardbuttons Export or Variants and include my own menu in this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can this be done? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;bert&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Oct 2008 14:29:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/cl-salv-table-create-button-group/m-p/4670042#M1098475</guid>
      <dc:creator>b_deterd2</dc:creator>
      <dc:date>2008-10-24T14:29:30Z</dc:date>
    </item>
    <item>
      <title>Re: CL_SALV_TABLE Create Button Group</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/cl-salv-table-create-button-group/m-p/4670043#M1098476</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Bert,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Caution: I don't think the same screen container can be used for the menu button (cl_gui_alv_grid) and the ALV-OM output (cl_salv_table).  Two separate containers could be used on screen 100, one for the menu button and one for the ALV-OM output, but I don't think that is an ideal solution.  I'll keep trying, but for now have a look at my original reply.  Maybe you or someone else out there can figure out another way.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;This can indeed be done&lt;/U&gt;&lt;/STRONG&gt;.  To demonstrate, I created a skeleton program with just one custom button (with two menu items attached to it).  As far as I can tell, this will only work for the ALV-OM grid option and not for the ALV-OM full screen option.  Maybe the fullscreen option could be a challenge for someone else reading this reply.  &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I looked in programs BCALV_GRID_08 and SALV_TEST_FUNCTIONS and sort of morphed together the two concepts.  Here are the steps to recreate my example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Step 1:&lt;/STRONG&gt; Create a new program (NOTE: In order to make the code as simple as possible for this forum reply, I removed the lines of code that actually output the SPLFI data.  I figured seeing some test data would not be important for understanding the menu button in an ALV-OM.)&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
REPORT  zjrg_alvom_demo_menu_button.

*----------------------------------------------------------------------*
*       CLASS lcl_gui_alv_grid DEFINITION
*----------------------------------------------------------------------*
CLASS lcl_gui_alv_grid DEFINITION INHERITING FROM cl_gui_alv_grid.
  PUBLIC SECTION.
    METHODS: set_toolbar_buttons_grid IMPORTING toolbar_table TYPE ttb_button.
ENDCLASS.                    "lcl_gui_alv_grid DEFINITION

* Global Data
DATA: ispfli        TYPE TABLE OF spfli,
      gr_table      TYPE REF TO cl_salv_table,
      gr_events     TYPE REF TO cl_salv_events_table,
      gr_alv_grid   TYPE REF TO lcl_gui_alv_grid,
      gr_container  TYPE REF TO cl_gui_custom_container,
      ok_code       TYPE syucomm.

*----------------------------------------------------------------------*
*       CLASS lcl_gui_alv_grid IMPLEMENTATION
*----------------------------------------------------------------------*
CLASS lcl_gui_alv_grid IMPLEMENTATION.

  METHOD set_toolbar_buttons_grid.
    CALL METHOD me-&amp;gt;set_toolbar_buttons
      EXPORTING
        toolbar_table = toolbar_table.
  ENDMETHOD.                    "set_toolbar_buttons_grid

ENDCLASS.                    "lcl_gui_alv_grid IMPLEMENTATION

*----------------------------------------------------------------------*
*       CLASS lcl_handle_events DEFINITION
*----------------------------------------------------------------------*
CLASS lcl_handle_events DEFINITION.
  PUBLIC SECTION.
    METHODS:
      handle_menu_button
        FOR EVENT menu_button OF cl_gui_alv_grid
            IMPORTING e_object e_ucomm,

      handle_menu_command
        FOR EVENT user_command OF cl_gui_alv_grid
            IMPORTING e_ucomm.

ENDCLASS.                    "lcl_handle_events DEFINITION

DATA: event_handler TYPE REF TO lcl_handle_events.

START-OF-SELECTION.

  SELECT * FROM spfli INTO TABLE ispfli.
  IF ispfli[] IS INITIAL.
    MESSAGE 'Nothing selected' TYPE 'I'.
    EXIT.
  ENDIF.

  IF cl_salv_table=&amp;gt;is_offline( ) EQ if_salv_c_bool_sap=&amp;gt;false.
    CREATE OBJECT gr_container
      EXPORTING
        container_name = 'CONTAINER'.
  ENDIF.

  TRY.
      cl_salv_table=&amp;gt;factory(
        EXPORTING
          r_container    = gr_container
          container_name = 'CONTAINER'
        IMPORTING
          r_salv_table   = gr_table
        CHANGING
          t_table        = ispfli ).
    CATCH cx_salv_msg.
  ENDTRY.

  CREATE OBJECT gr_alv_grid EXPORTING i_parent = gr_container.

  gr_events = gr_table-&amp;gt;get_event( ).

  CREATE OBJECT event_handler.

  SET HANDLER: event_handler-&amp;gt;handle_menu_button  FOR gr_alv_grid,
               event_handler-&amp;gt;handle_menu_command FOR gr_alv_grid.

* Display the ALV-OM Grid
  CALL SCREEN 100.

*----------------------------------------------------------------------*
*       CLASS lcl_handle_events IMPLEMENTATION
*----------------------------------------------------------------------*
CLASS lcl_handle_events IMPLEMENTATION.

  METHOD handle_menu_button.
    e_object-&amp;gt;add_function( EXPORTING fcode = 'CANC'
                                      text  = 'Cancel').

    e_object-&amp;gt;add_function( EXPORTING fcode = 'EXIT'
                                      text  = 'Exit').

  ENDMETHOD.                    "handle_menu_button

  METHOD handle_menu_command.
    CASE e_ucomm.
      WHEN 'EXIT'.
        MESSAGE 'Exit menu button option.' TYPE 'I'.
        LEAVE TO SCREEN 0.
      WHEN 'CANC'.
        MESSAGE 'Cacnel menu button option.' TYPE 'I'.
    ENDCASE.
  ENDMETHOD.                    "handle_menu_command

ENDCLASS.                    "lcl_handle_events IMPLEMENTATION
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Module  STATUS_0100  OUTPUT
*&amp;amp;---------------------------------------------------------------------*
MODULE status_0100 OUTPUT.

  DATA: it_toolbar TYPE ttb_button.
  FIELD-SYMBOLS: &amp;lt;fs_toolbar&amp;gt; TYPE stb_button.

  APPEND INITIAL LINE TO it_toolbar ASSIGNING &amp;lt;fs_toolbar&amp;gt;.
  &amp;lt;fs_toolbar&amp;gt;-function = 'MENUB'.
  &amp;lt;fs_toolbar&amp;gt;-butn_type = '1'.
  &amp;lt;fs_toolbar&amp;gt;-text = 'Menu test'.

  gr_alv_grid-&amp;gt;set_toolbar_buttons_grid( it_toolbar ).

  gr_table-&amp;gt;display( ).

ENDMODULE.                 " STATUS_0100  OUTPUT&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Step 2:&lt;/STRONG&gt; Create screen 100 for this program with a single custom control called CONTAINER and the following flow logic:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
process before output.
  module status_0100.
*
process after input.
*  
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Activate everything and run the program.  You should see a single custom button for an empty ALV-OM Grid.  This button has two menu items Cancel, and Exit.  Hopefully, this example will give you an idea of how to use this concept in your own development.  &lt;STRONG&gt;You can now use the normal ALV-OM methods to design the rest of your ALV grid output.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Jamie&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: James Gaddis on Oct 27, 2008 5:11 PM  - Did not need code for event handle_toolbar, so I removed it from the program sample.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: James Gaddis on Oct 28, 2008 2:28 PM - Upon further review....  read first paragraph.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Oct 2008 20:49:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/cl-salv-table-create-button-group/m-p/4670043#M1098476</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-27T20:49:27Z</dc:date>
    </item>
  </channel>
</rss>

