Menu Button in ALV toolbar (multiple choices for a button)

Hi abapers,
I would like to have a button with multiple choices in the toolbar;
at the moment I have created a menu button with just one function.
Here is my code:
CLASS lcl_event_receiver (Definition)
CLASS lcl_event_receiver DEFINITION.
  PUBLIC SECTION.
    METHODS:
    handle_toolbar
        FOR EVENT toolbar OF cl_gui_alv_grid
            IMPORTING e_object e_interactive.
ENDCLASS.                    "lcl_event_receiver DEFINITION
CLASS lcl_event_receiver (Implementation)
CLASS lcl_event_receiver IMPLEMENTATION.
  METHOD handle_toolbar.
    DATA: ls_toolbar  TYPE stb_button.
*Separator
    CLEAR ls_toolbar.
    MOVE 3 TO ls_toolbar-butn_type.
    APPEND ls_toolbar TO e_object->mt_toolbar.
*Button
    CLEAR ls_toolbar.
    MOVE 1 TO ls_toolbar-butn_type.
    MOVE 'EDIT' TO ls_toolbar-function.
    MOVE icon_change TO ls_toolbar-icon.
    MOVE ' Modifica'(l02) TO ls_toolbar-text.
    MOVE ' ' TO ls_toolbar-disabled.
    MOVE 'Modifica' TO ls_toolbar-quickinfo.
    APPEND ls_toolbar TO e_object->mt_toolbar.
  ENDMETHOD.                    "handle_toolbar
ENDCLASS.                    "lcl_event_receiver IMPLEMENTATION

hi,
check this code and reward me if it helps you..
TYPE-POOLS : slis,icon.
*Structure declaration for tcodes
TYPES : BEGIN OF ty_table,
        tcode TYPE tcode,
        pgmna TYPE progname,
        END OF ty_table.
*Structure for tocde text
TYPES : BEGIN OF ty_itext,
        tcode TYPE tcode,
        ttext TYPE ttext_stct,
        sprsl TYPE sprsl,
        END OF ty_itext.
*Structure for output display
TYPES : BEGIN OF ty_output,
        tcode TYPE tcode,
        pgmna TYPE progname,
        ttext TYPE ttext_stct,
       END OF ty_output.
*internal table and work area declarations
DATA : it_table TYPE STANDARD TABLE OF ty_table INITIAL SIZE 0,
       it_output TYPE STANDARD TABLE OF ty_output INITIAL SIZE 0,
       it_ittext TYPE STANDARD TABLE OF ty_itext INITIAL SIZE 0,
       wa_table TYPE ty_table,
       wa_output TYPE ty_output,
       wa_ittext TYPE ty_itext.
*Class definition for ALV toolbar
CLASS:      lcl_alv_toolbar   DEFINITION DEFERRED.
*Declaration for toolbar buttons
DATA : ty_toolbar TYPE stb_button.
Data declarations for ALV
DATA: c_ccont TYPE REF TO cl_gui_custom_container,   "Custom container object
      c_alvgd         TYPE REF TO cl_gui_alv_grid,   "ALV grid object
      it_fcat            TYPE lvc_t_fcat,            "Field catalogue
      it_layout          TYPE lvc_s_layo,            "Layout
      c_alv_toolbar    TYPE REF TO lcl_alv_toolbar,           "Alv toolbar
      c_alv_toolbarmanager TYPE REF TO cl_alv_grid_toolbar_manager.  "Toolbar manager
*Initialization event
INITIALIZATION.
*Start of selection event
START-OF-SELECTION.
*Subroutine to get values from tstc table
  PERFORM fetch_data.
*subroutine for alv display
  PERFORM alv_output.
      CLASS lcl_alv_toolbar DEFINITION
      ALV event handler
CLASS lcl_alv_toolbar DEFINITION.
  PUBLIC SECTION.
*Constructor
    METHODS: constructor
               IMPORTING
                 io_alv_grid TYPE REF TO cl_gui_alv_grid,
*Event for toolbar
    on_toolbar
       FOR EVENT toolbar
       OF  cl_gui_alv_grid
       IMPORTING
         e_object.
ENDCLASS.                    "lcl_alv_toolbar DEFINITION
      CLASS lcl_alv_toolbar IMPLEMENTATION
      ALV event handler
CLASS lcl_alv_toolbar IMPLEMENTATION.
  METHOD constructor.
  Create ALV toolbar manager instance
    CREATE OBJECT c_alv_toolbarmanager
      EXPORTING
        io_alv_grid      = io_alv_grid.
   ENDMETHOD.                    "constructor
  METHOD on_toolbar.
  Add customized toolbar buttons.
  variable for Toolbar Button
      ty_toolbar-icon      =  icon_generate.
    ty_toolbar-butn_type = 0.
    ty_toolbar-text = 'Button1'.
      APPEND ty_toolbar TO e_object->mt_toolbar.
      ty_toolbar-icon      =  icon_voice_output.
    ty_toolbar-butn_type = 0.
    ty_toolbar-text = 'Button2'.
       APPEND ty_toolbar TO e_object->mt_toolbar.
     ty_toolbar-icon      =  icon_phone.
    ty_toolbar-butn_type = 0.
    ty_toolbar-text = 'Button3'.
       APPEND ty_toolbar TO e_object->mt_toolbar.
     ty_toolbar-icon      =  icon_mail.
    ty_toolbar-butn_type = 0.
    ty_toolbar-text = 'Button4'.
       APPEND ty_toolbar TO e_object->mt_toolbar.
   ty_toolbar-icon      =  icon_voice_input.
    ty_toolbar-butn_type = 0.
    ty_toolbar-text = 'Button5'.
     APPEND ty_toolbar TO e_object->mt_toolbar.
  Call reorganize method of toolbar manager to
  display the toolbar
     CALL METHOD c_alv_toolbarmanager->reorganize
      EXPORTING
        io_alv_toolbar = e_object.
   ENDMETHOD.                    "on_toolbar
ENDCLASS.                    "lcl_alv_toolbar IMPLEMENTATION
*&      Form  fetch_data
      text
-->  p1        text
<--  p2        text
FORM fetch_data .
Select the tcodes upto 200 rows from TSTC
   SELECT   tcode
           pgmna
           FROM tstc
           INTO CORRESPONDING FIELDS OF TABLE it_table
           UP TO 200 ROWS
           WHERE dypno NE '0000'.
*Select the tcode textx
   IF it_table[] IS NOT INITIAL.
     SELECT ttext
           tcode
           sprsl
           FROM tstct
           INTO CORRESPONDING FIELDS OF TABLE it_ittext
           FOR ALL ENTRIES IN it_table
           WHERE tcode = it_table-tcode
           AND sprsl = 'E'.
   ENDIF.
Apppending the data to the internal table of ALV output
   LOOP AT it_table INTO wa_table.
    wa_output-tcode = wa_table-tcode.
    wa_output-pgmna = wa_table-pgmna.
   For texts
    READ TABLE it_ittext INTO wa_ittext WITH KEY tcode = wa_table-tcode.
    wa_output-ttext = wa_ittext-ttext.
     APPEND wa_output TO it_output.
    CLEAR wa_output.
   ENDLOOP.
   ENDFORM.                    " fetch_data
*&      Form  alv_output
      text
-->  p1        text
<--  p2        text
FORM alv_output .
*Calling the ALV
  CALL SCREEN 0600.
  ENDFORM.                    " alv_output
Calling the ALV screen with custom container
On this statement double click  it takes you to the screen painter SE51.Enter the attributes
*Create a Custom container and name it CC_CONT and OK code as OK_CODE.
*Save check and Activate the screen painter.
Now a normal screen with number 600 is created which holds the ALV grid. PBO of the actual screen , Here we can give a title and *customized menus
*&      Module  STATUS_0600  OUTPUT
      text
MODULE status_0600 OUTPUT.
SET PF-STATUS 'xxxxxxxx'.
SET TITLEBAR 'xxx'.
ENDMODULE.                 " STATUS_0600  OUTPUT
calling the PBO module ALV_GRID.
*&      Module  ALV_GRID  OUTPUT
      text
MODULE alv_grid OUTPUT.
*create object for custom container
  CREATE OBJECT c_ccont
       EXPORTING
          container_name = 'CC_CONT'.
*create object of alv grid
  CREATE OBJECT c_alvgd
      EXPORTING
          i_parent = c_ccont.
create ALV event handler
  CREATE OBJECT c_alv_toolbar
    EXPORTING
      io_alv_grid = c_alvgd.
Register event handler
  SET HANDLER c_alv_toolbar->on_toolbar FOR c_alvgd.
Fieldcatalogue for ALV
   PERFORM alv_build_fieldcat.
ALV attributes FOR LAYOUT
  PERFORM alv_report_layout.
   CHECK NOT c_alvgd IS INITIAL.
Call ALV GRID
   CALL METHOD c_alvgd->set_table_for_first_display
    EXPORTING
      is_layout                     = it_layout
    CHANGING
      it_outtab                     = it_output
      it_fieldcatalog               = it_fcat
    EXCEPTIONS
      invalid_parameter_combination = 1
      program_error                 = 2
      too_many_lines                = 3
      OTHERS                        = 4.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
ENDMODULE.                 " ALV_GRID  OUTPUT
*&      Form  alv_build_fieldcat
      text
     <--P_IT_FCAT  text
FORM alv_build_fieldcat.
   DATA lv_fldcat TYPE lvc_s_fcat.
  CLEAR lv_fldcat.
  lv_fldcat-row_pos   = '1'.
  lv_fldcat-col_pos   = '1'.
  lv_fldcat-fieldname = 'TCODE'.
  lv_fldcat-tabname   = 'IT_OUTPUT'.
  lv_fldcat-outputlen = 8.
  lv_fldcat-scrtext_m = 'TCODE'.
  APPEND lv_fldcat TO it_fcat.
  CLEAR lv_fldcat.
   lv_fldcat-row_pos   = '1'.
  lv_fldcat-col_pos   = '2'.
  lv_fldcat-fieldname = 'PGMNA'.
  lv_fldcat-tabname   = 'IT_OUTPUT'.
  lv_fldcat-outputlen = 15.
  lv_fldcat-scrtext_m = 'PROGNAME'.
  APPEND lv_fldcat TO it_fcat.
  CLEAR lv_fldcat.
  lv_fldcat-row_pos   = '1'.
  lv_fldcat-col_pos   = '3'.
  lv_fldcat-fieldname = 'TTEXT'.
  lv_fldcat-tabname   = 'IT_OUTPUT'.
  lv_fldcat-outputlen = 60.
  lv_fldcat-scrtext_m = 'Description'.
  APPEND lv_fldcat TO it_fcat.
  CLEAR lv_fldcat.
ENDFORM.                    " alv_build_fieldcat
*&      Form  alv_report_layout
      text
     <--P_IT_LAYOUT  text
FORM alv_report_layout.
   it_layout-cwidth_opt = 'X'.
   it_layout-zebra = 'X'.
ENDFORM.                    " alv_report_layout
PAI module of the screen created. In case we use an interactive ALV or
*for additional functionalities we can create OK codes
*and based on the user command we can do the coding.
*&      Module  USER_COMMAND_0600  INPUT
      text
MODULE user_command_0600 INPUT.
ENDMODULE.                 " USER_COMMAND_0600  INPUT
thanks,
gupta

Similar Messages

  • How to create multiple buttons in ALV Toolbar in Webdynpro ABAP

    Hi all,
    I am trying to create multiple buttons in Webdynpro  ALV toolbar, please go through the code.
    What happening is, second button is replacing the first one.
    DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.
       lo_cmp_usage =   wd_this->wd_cpuse_alv_table( ).
       IF lo_cmp_usage->has_active_component( ) IS INITIAL.
         lo_cmp_usage->create_component( ).
       ENDIF.
       DATA lo_interfacecontroller TYPE REF TO iwci_salv_wd_table .
       lo_interfacecontroller =   wd_this->wd_cpifc_alv_table( ).
        DATA lv_value TYPE REF TO cl_salv_wd_config_table.
       lv_value = lo_interfacecontroller->get_model(
       DATA lr_buttonui1 TYPE REF TO cl_salv_wd_fe_button.
       DATA lr_buttonui2 TYPE REF TO cl_salv_wd_fe_button.
       DATA button1 TYPE REF TO cl_salv_wd_function.
       DATA button2 TYPE REF TO cl_salv_wd_function.
    **First button
       CREATE OBJECT lr_buttonui1.
       lr_buttonui1->set_text('Button')."setting the text of the button on alv toolbar
       button1 = lv_value->if_salv_wd_function_settings~create_function( id = 'BUTTON')."creating the function for alv button
       button1->set_editor( lr_buttonui1 ).
    **Second button
       CREATE OBJECT lr_buttonui2.
         lr_buttonui2->set_text('Button1')."setting the text of the button on alv toolbar
       button2 = lv_value->if_salv_wd_function_settings~create_function( id = 'BUTTON' )."creating the function for alv button
       button2->set_editor( lr_buttonui2 ).
    How can I overcome this??
    Thanks
    Eshwar

    Hi Eshwar,
    The button Ids are same for both the buttons in your code. You need to change it as BUTTON1, BUTTON2.
    **First button
       CREATE OBJECT lr_buttonui1.
       lr_buttonui1->set_text('Button')."setting the text of the button on alv toolbar
       button1 = lv_value->if_salv_wd_function_settings~create_function( id = 'BUTTON1')."creating the function for alv button
       button1->set_editor( lr_buttonui1 ).
    **Second button
       CREATE OBJECT lr_buttonui2.
         lr_buttonui2->set_text('Button1')."setting the text of the button on alv toolbar
       button2 = lv_value->if_salv_wd_function_settings~create_function( id = 'BUTTON2' )."creating the function for alv button
       button2->set_editor( lr_buttonui2 ).

  • Add on custom button to ALV toolbar in std tcode ME51N, ME52N and ME53N.

    Hi All,
    I have the requirement to add on the custom button to ALV toolbar in ITEM OVERVIEW for standard transaction ME51N, ME52N and ME53N. Does anyone know what enhancement point or user exit i should apply and how i can add on the custom button?
    Thanks.

    There are no user exits or badi's for COOIS. You may have to make copy of the PPIO_ENTRY to ZPPIO_ENTRY including all the varians without changing their names like copy SAP&COOIS to SAP&COOIS. Create a T-Code ZCOOIS and replace COOIS in variant SAP&COOIS to ZCOOIS not in the name of the variant but in the field "Check Authorization for".
    The PF-Status is found in the include LCOISOUTPUTF16 which is located in the function group COISOUTPUT you may have to copy that too. Finally you need to copy SAPLCOISOUTPUT with its GUI status GENERAL and add your custom button there.

  • Is it possible to flip the multiple choice quiz "radio" button from left to right of the answers?

    Hello forum,
    I am using Captivate version 6.1.0.319 on a Windows 7 desktop PC and would like to know if it is possible to flip the multiple choice quiz "radio" button from left to right of the answers. I am working on a project that uses the "Require Right to Left composer" within the Global Preferences: General settings. The captions has been switched from left to right but the quiz answer radio buttons did not. Any help would be appreciated.
    Thanks, in advance. 

    Hello and welcome to the forum,
    I'm not aware of such a possibility. A workaround could be to create your own MCQ slides, using standard objects and widgets like the radiobuttons widget (there is an enhanced version created by Jim Leichliter) and advanced actions. These articles were written for previous versions, but can give you an idea about the work involved:
    http://blog.lilybiri.com/widgets-and-custom-questions-part-1
    http://blog.lilybiri.com/extended-widgets-for-custom-mcq-and-tf-questi
    Lilybiri

  • Radio button in ALV toolbar

    Hi experts,
    I have a requirement to add 2 radio buttons on ALV toolbar.
    I try to implement the toolbar event of class cl_gui_alv_grid, and add 2 radio buttons using the following code:
           move 'RAD' to ls_toolbar-function. 
           move 'RADIO1' to ls_toolbar-quickinfo.
           move 'RADIO1' to ls_toolbar-text.
           move '4' to ls_toolbar-butn_type.
           move ' ' to ls_toolbar-disabled.
           move 'X' to ls_toolbar-checked .
           append ls_toolbar to e_object->mt_toolbar.
           clear ls_toolbar.
           move 'RAD' to ls_toolbar-function.
           move 'RADIO2' to ls_toolbar-quickinfo.
           move 'RADIO2' to ls_toolbar-text.
           move '4' to ls_toolbar-butn_type.
           move ' ' to ls_toolbar-disabled. "#EC NOTEXT
           append ls_toolbar to e_object->mt_toolbar.
    But when I run this program,I find these 2 radio buttons look like normal button, is this correct?
    And I don't know how to catch which radio button is checked or not.
    Anyone having code for it or any suggestion for it, kindly let me know...
    Thank you
    Edited by: jie Wu on Nov 26, 2010 3:33 AM

    hello,
    I visit this address, but it does't meet my needs....
    I want to add radio button(button type 4) in ALV toolbar not the normal button(button type 0).
    The more important is I want to find a way to get properity of toolbar in ALV grid.
    Thank you.

  • Multiple choices for User's Profile& Preferences System Code for GSM ?

      Hello,
    I’m LauraJ and I have a question regarding users being able to see in GSM the item codes for specifications entered by other business units users.
    When this user is making a generic search in GSM for the common specifications shared by multiple facilities, on the search page he/she is seeing only the system code from its facility; the codes entered by sister facilities users for the same specification are visible only if he/she opens the spec.
    I tried to change this into User’s Profile& Preferences System Code for GSM but I can choose only one option. How can I select multiple choices for System code?
    thanks in advance!

    In GSM and SCRM, you can only select one preferred System Code. But you can create an Enhancement Request for use to allow multiple.

  • Button in ALV toolbar with REUSE_ALV_GRID_DISPLAY

    Hello friends,
    I am Displaying ALV using REUSE_ALV_GRID_IDSPLAY. i need to add a button in grid toolbar.
    i am doing it by adding a new ZSTATUS in  SET PF_STATUS. but the problem is that it is removing the standard buttons.
    i want to add button without removing the standard butttons.
    Please help.
    thanx in advance.
    Krishan Kumar

    hai friends.......
                       i had tried to add custom button to the reuse_alv_grid_display.please send  the coding...
    REPORT  ZHAJI_SAMPLE.
    tables:lfa1.
    TYPE-POOLS : slis.
    SELECT-OPTIONS: lifnr FOR lfa1-lifnr.
    types:begin of fs,
          flag type c,
          lifnr type lfa1-lifnr,
          land1 type lfa1-land1,
          name1 type lfa1-name1,
          end of fs.
    data: itab type table of fs,
          wa type fs.
    data: fcat type slis_t_fieldcat_alv,
          fcat1 type slis_fieldcat_alv.
    data: rt_extab type slis_t_extab.
    *CONSTANTS : c_check(1) VALUE 'X'.
    select lifnr land1 name1 from lfa1 into corresponding FIELDS OF table
    itab where lifnr IN
    lifnr.
    perform sub.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
       I_CALLBACK_PROGRAM                = 'sy-repid'
       I_CALLBACK_PF_STATUS_SET           = 'PF'
      I_CALLBACK_USER_COMMAND           = ' '
      I_CALLBACK_TOP_OF_PAGE            = ' '
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
    I_GRID_TITLE                      = 'vendor details'
      I_GRID_SETTINGS                   =
    IS_LAYOUT                         = LAYOUT
       IT_FIELDCAT                       = fcat
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
      I_SAVE                            = ' '
      IS_VARIANT                        =
    IT_EVENTS                         = I_EVENT
      IT_EVENT_EXIT                     =
      IS_PRINT                          =
      IS_REPREP_ID                      =
      I_SCREEN_START_COLUMN             = 0
      I_SCREEN_START_LINE               = 0
      I_SCREEN_END_COLUMN               = 0
      I_SCREEN_END_LINE                 = 0
      IT_ALV_GRAPHICS                   =
      IT_HYPERLINK                      =
      IT_ADD_FIELDCAT                   =
      IT_EXCEPT_QINFO                   =
      I_HTML_HEIGHT_TOP                 =
      I_HTML_HEIGHT_END                 =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
      TABLES
        T_OUTTAB                          = itab
    EXCEPTIONS
      PROGRAM_ERROR                     = 1
      OTHERS                            = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    form sub.
    fcat1-fieldname = 'FLAG'.
    fcat1-tabname = 'TAB'.
    *fcat1-COL_POS = 1.
    fcat1-checkbox = 'X'.
    fcat1-edit         = 'X'.
    append fcat1 to fcat.
    CLEAR FCAT1.
    fcat1-fieldname = 'LIFNR'.
    fcat1-ref_tabname = 'LFA1'.
    fcat1-ref_fieldname = 'LIFNR'.
    FCAT1-outputlen = 10.
    append fcat1 to fcat.
    CLEAR FCAT1.
    fcat1-fieldname = 'NAME1'.
    fcat1-ref_tabname = 'LFA1'.
    fcat1-ref_fieldname = 'NAME1'.
    append fcat1 to fcat.
    CLEAR FCAT1.
    fcat1-fieldname = 'LAND1'.
    fcat1-ref_tabname = 'LFA1'.
    fcat1-ref_fieldname = 'LAND1'.
    append fcat1 to fcat.
    CLEAR FCAT1.
    endform.
    form PF USING rt_extab TYPE slis_t_extab.
    SET PF-STATUS 'ZHAJI_P1' .
    ENDFORM.
    just give the fine coding

  • Buttons on ALV toolbar

    Hi all,
    I have developed an ALV Grid with a button SAVE.
    The list that is displayed in ALV  will be saved to ZTABLE when user clicks the SAVE button.
    My requirement is after that , I need to add a DISPLAY to the same ALV GRID TOOLBAR.
    How can I do it? do I have to CALL METHOD g_grid->set_table_for_first_display again?
    Thanks
    MH

    Hello
    The sample report for dealing with ALV toolbar buttons is BCALV_GRID_05.
    I assume that as long as your ALV grid is editable the user should see the SAVE button. As soon as the user has saved the data the grid changes to Display-only (non-editable) and the DISPLAY button should appear.
    If so then you can use method go_grid->IS_READY_FOR_INPUT( ) within the event handler method handle_toolbar.
    The sample report explaining this method is BCALV_EDIT_01.
    Regards
      Uwe
    PS: There is no need to call go_grid->set_table_for_first_display again, simply use go_grid->refresh_table_display.

  • How to hide 'layout button' on ALV toolbar

    Hi,
    I have an ALV and it has standard toolbar, now i want to hide 'Layout button' from the toolbar based on specific condition e.g when flag = 1.
    How to do that.
    Thanks,

    If you are using the REUSE function, you can use the "EXCLUDING" parameter, and pass the FCODE for "Change Layout" to this table.  This will remove the icon from the toolbar.  Here is an example.
    REPORT rich_0001 .
    * Global ALV Data Declarations
    TYPE-POOLS: slis.
    * Internal Tables
    DATA: BEGIN OF ialv OCCURS 0,
          test1(10) TYPE c,
          test2(10) TYPE c,
          END OF ialv.
    DATA: xfc TYPE slis_fieldcat_alv.
    DATA: ifc  TYPE slis_t_fieldcat_alv.
    DATA: iexcluding TYPE  slis_t_extab.
    DATA: xexcluding LIKE LINE OF iexcluding.
    PARAMETERS: p_hide TYPE c DEFAULT 'X'.
    START-OF-SELECTION.
      REFRESH iexcluding.
    * If the user wants to hide the change layout icon, then add to IEXCUDING
      IF p_hide = 'X'.
        xexcluding-fcode = '&OL0'.
        APPEND xexcluding TO iexcluding.
      ENDIF.
      REFRESH ifc.
      xfc-reptext_ddic = 'Test1'.
      xfc-fieldname    = 'TEST1'.
      xfc-outputlen    = '10'.
      APPEND xfc TO ifc.
      xfc-reptext_ddic = 'Test2'.
      xfc-fieldname    = 'TEST2'.
      xfc-outputlen    = '10'.
      APPEND xfc TO ifc.
    * Call ABAP List Viewer (ALV)
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          it_excluding = iexcluding
          it_fieldcat  = ifc
        TABLES
          t_outtab     = ialv.
    Regards,
    Rich Heilman

  • Adding an EXIT button in  ALV toolbar

    Hi,
        i want to add an exit button in my ALV toolbar wherein it should exit the browser or the URL which displays the output. Plzz help me on this.
    Thanks.

    Hi,
    the following code may help you:
    DATA:
    l_ref_cmp_usage          TYPE REF TO if_wd_component_usage,
    l_interface                    TYPE REF TO iwci_salv_wd_table,
    lr_table                        TYPE REF TO cl_salv_wd_config_table.
    create alv component
    l_ref_cmp_usage = wd_this->wd_cpuse_<name_of_alv_comp>( ).
    IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.
    l_ref_cmp_usage->create_component( ).
    ENDIF.
    get config models
      l_interface = wd_this->wd_cpifc_alv_activities_prdstd( ).
      lr_table = l_interface->get_model( ).
    create the toolbar button
    DATA:
    lr_functions TYPE REF TO if_salv_wd_function_settings,
    lr_function  TYPE REF TO cl_salv_wd_function,
    lr_fe_button TYPE REF TO cl_salv_wd_fe_button.
    lr_functions ?= lr_table.
    lr_function = lr_functions->create_function( 'MYBUTTON' ).
    CREATE OBJECT lr_fe_button.
    lr_fe_button->set_text( 'MyButton' ).
    lr_function->set_editor( lr_fe_button ).
    After that add an event handler for the ON_FUNCTION event of the alv. In this method you can do whatever you want.
    Kind Regards,
    Anika

  • Hide Change Layout Button in ALV report o/p for MB52 Tcode

    Hi,
    Is it possible to Hide Change Layout Button in ALV output for Report MB52 using authoriztaion.
    We have created a layout in which we are hiding some coloumns which the user should not see.
    But if the change layout button is active then the user can add those coloumns to output.
    Is this possible through authorizations. I want to avoid doing any chnages to the std sap program.
    Thanks & Regards,
    Fawaz

    Check the object S_ALV_LAYO

  • Hide 'Change Layout' button from alv toolbar

    Hello All,
    can anyone let me know how can we hide the change layout button or exclude the change layout button from the ALV tool bar using OOPS . what's the fcode for it.
    Thank You !
    Ravi

    Hi Ravi,
    Please refer to this [Program|http://www.saptechies.com/disable-some-standard-buttons-from-alv-display/].
    Hope this helps.
    Regards,
    Chandravadan

  • How to code in the standard refresh button in ALV toolbar

    Hi Experts,
    My ALV includes some standard toolbar buttons like refresh, select all, sort, and etc. How can I put logic into the refresh button such that when user click on the refresh button, I want to run some logic on my own?
    THanks in advance.

    Hi again,
    1. Further to my previous reply
    2. This code will make it clear.
    3. just copy paste
    a. Before that, copy the SALV Standard Toolbar to ABCD as suggested before.
    <b>Important & Relevant code has been marked in bold.</b>
    4.
    report abc.
    type-pools : slis.
    Data
    data : itab like t001 occurs 0 with header line.
    DATA : fc type SLIS_T_FIELDCAT_ALV.
    Logic
    select * from t001 into table itab.
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
      EXPORTING
        I_PROGRAM_NAME         = sy-repid
        I_INTERNAL_TABNAME     = 'ITAB'
        I_INCLNAME             = SY-REPID
      CHANGING
        CT_FIELDCAT            = fc
      EXCEPTIONS
        INCONSISTENT_INTERFACE = 1
        PROGRAM_ERROR          = 2
        OTHERS                 = 3.
    Display
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
      I_INTERFACE_CHECK              = ' '
      I_BYPASSING_BUFFER             =
      I_BUFFER_ACTIVE                = ' '
       I_CALLBACK_PROGRAM             =  SY-REPID
    <b>   I_CALLBACK_PF_STATUS_SET       = 'MYSTATUS '</b>
    <b>   I_CALLBACK_USER_COMMAND        = 'MYFORM'</b>   IT_FIELDCAT                    = FC
      TABLES
        T_OUTTAB                       = ITAB
    EXCEPTIONS
       PROGRAM_ERROR                  = 1
       OTHERS                         = 2
    <b>
    IMPORTANT
    This sets the PF Status on ALV Screen
    And not Selection screen
    FORM MYSTATUS USING rt_extab TYPE slis_t_extab.
      SET PF-STATUS 'ABCD'.
    ENDFORM.                    "MYSTATUS
    IMPORTANT
    When Fcode is pressed on ALV Toolbar
    FORM MYFORM USING r_ucomm LIKE sy-ucomm
                                       rs_selfield TYPE slis_selfield.
      IF R_UCOMM = 'ZREFRESH'.
    *----CODE
      ENDIF.
    ENDFORM.                    "MYFORM</b>
    regards,
    amit m.

  • How to add Change Layout Button to ALV Toolbar?

    Hi All,
    I am using a SAP GUI STATUS 'STANDARD' that has almost all the funcationality needed except for the change layout button.
    I have tried changing the GUI STATUS to 'STANDARD_FULLSCREEN' which has the button I am looking for but it does not show up.
    What am I missing to have the 'Change Layout' Button show on the toolbar?
    thank you

    I am using Classes.
    I did not specify any type of table of 'exclude' buttons.
    here is my code that display the ALV
    DATA gr_alv TYPE REF TO cl_salv_table.
    DATA gr_functions TYPE REF TO cl_salv_functions_list.
    DATA gr_selections TYPE REF TO cl_salv_selections.
    DATA gr_events TYPE REF TO cl_salv_events_table.
    DATA gr_settings TYPE REF TO cl_salv_display_settings.
    DATA gr_layout TYPE REF TO cl_salv_layout.
      TRY.
          cl_salv_table=>factory(
           IMPORTING r_salv_table = gr_alv
           CHANGING  t_table      = gt_rpt_details ).
          PERFORM f_display_settings.
          gr_alv->set_screen_status(
          "pfstatus = 'Z_STANDARD'
          pfstatus = 'ZSTANDARD_FULLSCREEN'
          report = sy-repid
          "i_save = 'A'
          set_functions = gr_alv->c_functions_all ).
          gr_events = gr_alv->get_event( ).
          "create layout object
          CREATE OBJECT gr_layout.
          gr_layout->get_current_layout( ).
          CREATE OBJECT event_handler.
          SET HANDLER event_handler->on_user_command FOR gr_events.
          gr_functions = gr_alv->get_functions( ).
          gr_functions->set_all('X').
          gr_functions->set_group_filter( value = if_salv_c_bool_sap=>false ).
    *       Set print preview
          gr_functions->set_print_preview( ).
          gr_alv->get_display_settings( ).
          gr_alv->display( ).

  • How to disable self defined button from ALV Toolbar when ok_code ='BACK'

    here is the code
    CLASS Z_CL_6_U_EVENT_RECEIVER DEFINITION.
      PUBLIC SECTION.
        METHODS:
          HANDLE_TOOLBAR
            FOR EVENT TOOLBAR OF CL_GUI_ALV_GRID
                IMPORTING E_OBJECT E_INTERACTIVE,
          HANDLE_USER_COMMAND
            FOR EVENT USER_COMMAND OF CL_GUI_ALV_GRID
                IMPORTING E_UCOMM.
    ENDCLASS.         
    CLASS  Z_CL_6_U_EVENT_RECEIVER IMPLEMENTATION.
      METHOD HANDLE_TOOLBAR.
    DATA: LS_TOOLBAR  TYPE STB_BUTTON.
    IF G_FLAG = 'X' and ok_code = space.
          CLEAR LS_TOOLBAR.
           MOVE 0 TO LS_TOOLBAR-BUTN_TYPE.
          MOVE 'UPDATE' TO LS_TOOLBAR-FUNCTION.
          MOVE  ICON_MODIFY  TO LS_TOOLBAR-ICON.
          MOVE 'Update Records'(111) TO LS_TOOLBAR-QUICKINFO.
          MOVE ''(112) TO LS_TOOLBAR-TEXT.
          MOVE ' ' TO LS_TOOLBAR-DISABLED.
          APPEND LS_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
    elseif ok_code = 'BACK'.
          CLEAR LS_TOOLBAR.
      LS_TOOLBAR-function = 'UPDATE'.
      LS_TOOLBAR-butn_type = 0.
      LS_TOOLBAR-icon = ICON_MODIFY.
      LS_TOOLBAR-quickinfo = 'Update Records'.
      LS_TOOLBAR-disabled = 'X'.
      append LS_TOOLBAR TO <i><b>E_OBJECT</b></i>->MT_TOOLBAR.
    ENDIF.
      ENDMETHOD. 
    <i><b>ERROR COMES when ok_code is 'BACK'.
    at this point E_OBJECT has null reference instead of ref to Class cl_ALV_EVENT_TOOLBAR_SET.</b></i> 
    tell me why this error coming.
    pls help

    Hello Neetu
    To give you an example I have copied sample report BCALV_GRID_DEMO, added some code (search for <b>$Comment</b>) and modified the GUI-status <b>MAIN100</b> (replace function code EXIT with <b>BACK</b> for the F3 function).
    Run the program and push several times the BACK button: one toolbar function after the other will be inactivated.
    PROGRAM test.
    DATA: ok_code LIKE sy-ucomm,
          gt_sflight TYPE TABLE OF sflight,
          g_container TYPE scrfname VALUE 'BCALV_GRID_DEMO_0100_CONT1',
          grid1  TYPE REF TO cl_gui_alv_grid,
          g_custom_container TYPE REF TO cl_gui_custom_container.
    <b>----
          CLASS lcl_eventhandler DEFINITION
    CLASS lcl_eventhandler DEFINITION.
      PUBLIC SECTION.
        CLASS-DATA:
          md_cnt    TYPE i.
        CLASS-METHODS:
          handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
            IMPORTING
              e_object
              e_interactive
              sender.
    ENDCLASS.                    "lcl_eventhandler DEFINITION
          CLASS lcl_eventhandler IMPLEMENTATION
    CLASS lcl_eventhandler IMPLEMENTATION.
      METHOD handle_toolbar.
        DATA:
          ls_button    TYPE stb_button.
        ADD 1 TO md_cnt. " a simple counter
        LOOP AT e_object->mt_toolbar INTO ls_button FROM 1 TO md_cnt.
          ls_button-disabled = 'X'.
          MODIFY e_object->mt_toolbar FROM ls_button.
        ENDLOOP.
      ENDMETHOD.                    "handle_toolbar
    ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION</b>
    START-OF-SELECTION.
    *       MAIN                                                          *
      SELECT * FROM sflight INTO TABLE gt_sflight.
      CALL SCREEN 100.
    *       MODULE PBO OUTPUT                                             *
    MODULE pbo OUTPUT.
      SET PF-STATUS 'MAIN100'.
      IF g_custom_container IS INITIAL.
        CREATE OBJECT g_custom_container
               EXPORTING container_name = g_container.
    *   Instantiate ALV grid control
        CREATE OBJECT grid1
               EXPORTING i_parent = g_custom_container.
        CALL METHOD grid1->set_table_for_first_display
          EXPORTING
            i_structure_name = 'SFLIGHT'
          CHANGING
            it_outtab        = gt_sflight.
    <b>*$Comment: Set event handler for event TOOLBAR
        SET HANDLER:
          lcl_eventhandler=>handle_toolbar FOR grid1.
      ENDIF.</b>
    ENDMODULE.                    "PBO OUTPUT
    *       MODULE PAI INPUT                                              *
    MODULE pai INPUT.
    *   to react on oi_custom_events:
      CALL METHOD cl_gui_cfw=>dispatch.
      CASE ok_code.
        WHEN 'EXIT'.
          PERFORM exit_program.
    <b>    WHEN 'BACK'.
    $Comment: Toolbar can be modified on-the-fly
          grid1->set_toolbar_interactive( ).</b>
        WHEN OTHERS.
    *     do nothing
      ENDCASE.
      CLEAR ok_code.
    ENDMODULE.                    "PAI INPUT
    *       FORM EXIT_PROGRAM                                             *
    FORM exit_program.
    *  CALL METHOD G_CUSTOM_CONTAINER->FREE.
    *  CALL METHOD CL_GUI_CFW=>FLUSH.
      LEAVE PROGRAM.
    ENDFORM.                    "EXIT_PROGRAM
    Regards
      Uwe

Maybe you are looking for