<?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 Alv Help in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-help/m-p/3618810#M871776</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 wont to now how i add  buttons to alv (like export the table to excel and other ...), i use 00 alv like below and i be happy to get some  comment  to do this better :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;*&amp;amp;      Module  PBO  OUTPUT
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE pbo OUTPUT.

  SET PF-STATUS 'MAIN100'.
  SET TITLEBAR  'MAIN100'.

  IF g_custom_container IS INITIAL.
    CREATE OBJECT g_custom_container
           EXPORTING container_name = g_container.
    CREATE OBJECT grid1
           EXPORTING i_parent = g_custom_container.
    gs_layout-grid_title = text-001.
    CALL METHOD grid1-&amp;gt;set_table_for_first_display
      EXPORTING
        i_structure_name = 'YHR_EX_T_STR'(002)
        is_layout        = gs_layout
        is_variant       = variant
        i_save           = 'A'
      CHANGING
        it_outtab        = teken_itab
        it_fieldcatalog  = fcat.
  ENDIF.



ENDMODULE.                 " PBO  OUTPUT

MODULE pai INPUT.

  CALL METHOD cl_gui_cfw=&amp;gt;dispatch.
  CASE ok_code.
    WHEN 'EXIT'.
      PERFORM exit_program.
    WHEN OTHERS.
  ENDCASE.
  CLEAR ok_code.


ENDMODULE.                 " PAI  INPUT


FORM exit_program.

*  CALL METHOD G_CUSTOM_CONTAINER-&amp;gt;FREE.
*  CALL METHOD CL_GUI_CFW=&amp;gt;FLUSH.

  LEAVE PROGRAM.
ENDFORM.                    "EXIT_PROGRAM

FORM create_field_cat .


  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
      i_structure_name       = 'YHR_EX_T_STR'   "STRUCTRE NAME
    CHANGING
      ct_fieldcat            = ct_fieldcat
    EXCEPTIONS
      inconsistent_interface = 1
      program_error          = 2
      OTHERS                 = 3.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 26 Mar 2008 17:28:34 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-03-26T17:28:34Z</dc:date>
    <item>
      <title>Alv Help</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-help/m-p/3618810#M871776</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 wont to now how i add  buttons to alv (like export the table to excel and other ...), i use 00 alv like below and i be happy to get some  comment  to do this better :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;*&amp;amp;      Module  PBO  OUTPUT
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE pbo OUTPUT.

  SET PF-STATUS 'MAIN100'.
  SET TITLEBAR  'MAIN100'.

  IF g_custom_container IS INITIAL.
    CREATE OBJECT g_custom_container
           EXPORTING container_name = g_container.
    CREATE OBJECT grid1
           EXPORTING i_parent = g_custom_container.
    gs_layout-grid_title = text-001.
    CALL METHOD grid1-&amp;gt;set_table_for_first_display
      EXPORTING
        i_structure_name = 'YHR_EX_T_STR'(002)
        is_layout        = gs_layout
        is_variant       = variant
        i_save           = 'A'
      CHANGING
        it_outtab        = teken_itab
        it_fieldcatalog  = fcat.
  ENDIF.



ENDMODULE.                 " PBO  OUTPUT

MODULE pai INPUT.

  CALL METHOD cl_gui_cfw=&amp;gt;dispatch.
  CASE ok_code.
    WHEN 'EXIT'.
      PERFORM exit_program.
    WHEN OTHERS.
  ENDCASE.
  CLEAR ok_code.


ENDMODULE.                 " PAI  INPUT


FORM exit_program.

*  CALL METHOD G_CUSTOM_CONTAINER-&amp;gt;FREE.
*  CALL METHOD CL_GUI_CFW=&amp;gt;FLUSH.

  LEAVE PROGRAM.
ENDFORM.                    "EXIT_PROGRAM

FORM create_field_cat .


  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
      i_structure_name       = 'YHR_EX_T_STR'   "STRUCTRE NAME
    CHANGING
      ct_fieldcat            = ct_fieldcat
    EXCEPTIONS
      inconsistent_interface = 1
      program_error          = 2
      OTHERS                 = 3.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Mar 2008 17:28:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-help/m-p/3618810#M871776</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-26T17:28:34Z</dc:date>
    </item>
    <item>
      <title>Re: Alv Help</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-help/m-p/3618811#M871777</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;
" You need to fill variant structure with the following

    variant-report       = sy-repid.
    variant-username     = sy-uname.

    CALL METHOD grid1-&amp;gt;set_table_for_first_display
      EXPORTING
        i_structure_name = 'YHR_EX_T_STR'(002)
        is_layout        = gs_layout
        is_variant       = variant
        i_save           = 'A'
      CHANGING
        it_outtab        = teken_itab
        it_fieldcatalog  = fcat.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; a®&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Mar 2008 17:57:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-help/m-p/3618811#M871777</guid>
      <dc:creator>former_member194669</dc:creator>
      <dc:date>2008-03-26T17:57:14Z</dc:date>
    </item>
    <item>
      <title>Re: Alv Help</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-help/m-p/3618812#M871778</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;For excluding some standard buttons on the toolbar,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
FORM exclude_tb_functions CHANGING pt_exclude TYPE ui_functions .

DATA ls_exclude TYPE ui_func.
" for excluding the buttons on the alv toolbar
  ls_exclude = cl_gui_alv_grid=&amp;gt;mc_fc_maximum .
  APPEND ls_exclude TO pt_exclude.
  ls_exclude = cl_gui_alv_grid=&amp;gt;mc_fc_minimum .
  APPEND ls_exclude TO pt_exclude.
  ls_exclude = cl_gui_alv_grid=&amp;gt;mc_fc_subtot .
  APPEND ls_exclude TO pt_exclude.
  ls_exclude = cl_gui_alv_grid=&amp;gt;mc_fc_sum .
  APPEND ls_exclude TO pt_exclude.
  ls_exclude = cl_gui_alv_grid=&amp;gt;mc_fc_average .
  APPEND ls_exclude TO pt_exclude.
" for excluding the menu function
  ls_exclude = cl_gui_alv_grid=&amp;gt;mc_mb_sum .
  APPEND ls_exclude TO pt_exclude.
  ls_exclude = cl_gui_alv_grid=&amp;gt;mc_mb_subtot .
  APPEND ls_exclude TO pt_exclude.
ENDFORM .
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here, names beginning with &amp;#147;MC_FC_&amp;#148; are names for functions directly and the names beginning with &amp;#147;MC_MB_&amp;#148; are for the function menus including some subfunctions as menu entries. By excluding one from the latter type, you exclude all of the functions under it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check the below code for event handler local class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
"Event Handler Class
CLASS lcl_event_handler DEFINITION .
PUBLIC SECTION .
METHODS:
*To add new functional buttons to the ALV toolbar
handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object e_interactive .
ENDCLASS.

CLASS lcl_event_handler IMPLEMENTATION .
*Handle Toolbar
METHOD handle_toolbar.
PERFORM handle_toolbar USING e_object e_interactive .
ENDMETHOD .
ENDCLASS.

DATA gr_event_handler TYPE REF TO lcl_event_handler .
.. ..
*--Creating an instance for the event handler
CREATE OBJECT gr_event_handler .
*--Registering handler methods to handle ALV Grid events
SET HANDLER gr_event_handler-&amp;gt;handle_toolbar FOR gr_alvgrid .
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ALV Grid control has an open door letting you to add your own functions triggered by a button press on the ALV toolbar. For this, we mainly utilize two of ALV Grid events. We use the event &amp;#147;toolbar&amp;#148; to add the button and the event &amp;#147;user_command&amp;#148; to implement the new function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the method handling the &amp;#147;toolbar&amp;#148; event, we define a new button by filling a structure and appending it to the table attribute &amp;#147;mt_toolbar&amp;#148; of the object to whose reference we can reach via the parameter &amp;#147;e_object&amp;#148; of the event.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

FORM handle_toolbar USING i_object TYPE REF TO cl_alv_event_toolbar_set .
DATA: ls_toolbar TYPE stb_button.
CLEAR ls_toolbar.
MOVE 3 TO ls_toolbar-butn_type.
APPEND ls_toolbar TO i_object-&amp;gt;mt_toolbar.
CLEAR ls_toolbar.
MOVE 'PER' TO ls_toolbar-function. "#EC NOTEXT
MOVE icon_display_text TO ls_toolbar-icon.
MOVE 'Passenger Info'(201) TO ls_toolbar-quickinfo.
MOVE 'Passenger Info'(201) TO ls_toolbar-text.
MOVE ' ' TO ls_toolbar-disabled. "#EC NOTEXT
APPEND ls_toolbar TO i_object-&amp;gt;mt_toolbar.
CLEAR ls_toolbar.
MOVE 'EXCH' TO ls_toolbar-function. "#EC NOTEXT
MOVE 2 TO ls_toolbar-butn_type.
MOVE icon_calculation TO ls_toolbar-icon.
MOVE 'Payment in Other Currencies'(202) TO ls_toolbar-quickinfo.
MOVE ' ' TO ls_toolbar-text.
MOVE ' ' TO ls_toolbar-disabled. "#EC NOTEXT
APPEND ls_toolbar TO i_object-&amp;gt;mt_toolbar.
ENDFORM .

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps. Reward points if helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Balaji&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Mar 2008 18:00:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-help/m-p/3618812#M871778</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-26T18:00:50Z</dc:date>
    </item>
    <item>
      <title>Re: Alv Help</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-help/m-p/3618813#M871779</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 check demo program BCALV_GRID_08 to add buttons using TOOLBAR event of CL_GUI_ALV_GRID.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also you can check this link for sample program on how to add buttons using FM REUSE_ALV_LIST_DISPLAY.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sap-basis-abap.com/abap/add-button-to-alv-toolbar-with-reuse-alv-list-display.htm" target="test_blank"&gt;http://www.sap-basis-abap.com/abap/add-button-to-alv-toolbar-with-reuse-alv-list-display.htm&lt;/A&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;Ferry Lianto&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Mar 2008 18:10:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-help/m-p/3618813#M871779</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-26T18:10:22Z</dc:date>
    </item>
  </channel>
</rss>

