Need to Add a button in ALV Tool Bar

Hi,
I have a requirement where in i need to add a button to a standard ALV report. Its using the class CL_GUI_ALV_GRID. There is a Badi for the report. The Report is co05n and the Badi is WORKORDER_INFOSYSTEM . I am getting the handle of
CL_GUI_ALV_GRID object reference before screen display. Any guidance on how to add new button now to that toolbar?
Any help will be rewarded.
Thank you.
regards,
Deepthi lakshmi.A.

Dear Deepthi Lakshmi.A.,
Refer the standard program BCALV_GRID_05                  Add a Self-Defined Button to the Toolbar.
PROGRAM BCALV_GRID_05.
Purpose:
~~~~~~~~
Demonstrate the creation of an own toolbar button.
To check program behavior
~~~~~~~~~~~~~~~~~~~~~~~~~
The report shows a list of flights of one airline.
Select one or more lines and press the 'Detail'-Button to popup
a dialog window with related bookings.
Essential steps (Search for '§')
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1.Apply steps for event handling for events TOOLBAR and
  USER_COMMAND (see example for print events)
2.In event handler method for event TOOLBAR: Append own functions
  by using event parameter E_OBJECT.
3.In event handler method for event USER_COMMAND: Query your
  function codes defined in step 2 and react accordingly.
4.Call method 'set_toolbar_interactive' to raise event TOOLBAR.
INCLUDE .
Predefine a local class for event handling to allow the
declaration of a reference variable before the class is defined.
CLASS lcl_event_receiver DEFINITION DEFERRED.
DATA: ok_code LIKE sy-ucomm,
      gt_sflight TYPE TABLE OF sflight,
      gt_sbook TYPE TABLE OF sbook,
      g_repid LIKE sy-repid,
      g_max type i value 100,
      gs_layout   TYPE lvc_s_layo,
      cont_on_main   TYPE scrfname VALUE 'BCALVC_TOOLBAR_D100_C1',
      cont_on_dialog TYPE scrfname VALUE 'BCALVC_TOOLBAR_D101_C1',
      grid1  TYPE REF TO cl_gui_alv_grid,
      grid2  TYPE REF TO cl_gui_alv_grid,
      custom_container1 TYPE REF TO cl_gui_custom_container,
      custom_container2 TYPE REF TO cl_gui_custom_container,
      event_receiver TYPE REF TO lcl_event_receiver.
Set initial dynpro
SET SCREEN 100.
LOCAL CLASSES: Definition
*===============================================================
class lcl_event_receiver: local class to
                        define and handle own functions.
Definition:
~~~~~~~~~~~
CLASS lcl_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.
  PRIVATE SECTION.
ENDCLASS.
lcl_event_receiver (Definition)
*===============================================================
LOCAL CLASSES: Implementation
*===============================================================
class lcl_event_receiver (Implementation)
CLASS lcl_event_receiver IMPLEMENTATION.
  METHOD handle_toolbar.
§ 2.In event handler method for event TOOLBAR: Append own functions
  by using event parameter E_OBJECT.
    DATA: ls_toolbar  TYPE stb_button.
E_OBJECT of event TOOLBAR is of type REF TO CL_ALV_EVENT_TOOLBAR_SET.
This class has got one attribute, namly MT_TOOLBAR, which
is a table of type TTB_BUTTON. One line of this table is
defined by the Structure STB_BUTTON (see data deklaration above).
A remark to the flag E_INTERACTIVE:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        'e_interactive' is set, if this event is raised due to
        the call of 'set_toolbar_interactive' by the user.
        You can distinguish this way if the event was raised
        by yourself or by ALV
        (e.g. in method 'refresh_table_display').
        An application of this feature is still unknown...
append a separator to normal toolbar
    CLEAR ls_toolbar.
    MOVE 3 TO ls_toolbar-butn_type.
    APPEND ls_toolbar TO e_object->mt_toolbar.
append an icon to show booking table
    CLEAR ls_toolbar.
    MOVE 'BOOKINGS' TO ls_toolbar-function.
    MOVE icon_employee TO ls_toolbar-icon.
    MOVE 'Show Bookings'(111) TO ls_toolbar-quickinfo.
    MOVE 'Detail'(112) TO ls_toolbar-text.
    MOVE ' ' TO ls_toolbar-disabled.
    APPEND ls_toolbar TO e_object->mt_toolbar.
  ENDMETHOD.
  METHOD handle_user_command.
§ 3.In event handler method for event USER_COMMAND: Query your
  function codes defined in step 2 and react accordingly.
    DATA: lt_rows TYPE lvc_t_row.
    CASE e_ucomm.
      WHEN 'BOOKINGS'.
        CALL METHOD grid1->get_selected_rows
                 IMPORTING et_index_rows = lt_rows.
        CALL METHOD cl_gui_cfw=>flush.
        IF sy-subrc ne 0.
add your handling, for example
          CALL FUNCTION 'POPUP_TO_INFORM'
               EXPORTING
                    titel = g_repid
                    txt2  = sy-subrc
                    txt1  = 'Error in Flush'(500).
        else.
                  perform show_booking_table tables lt_rows.
        ENDIF.
    ENDCASE.
  ENDMETHOD.                           "handle_user_command
ENDCLASS.
lcl_event_receiver (Implementation)
*===================================================================
      FORM EXIT_PROGRAM                                             *
FORM exit_program.
The instance grid2 is freed not until the program exits from the
main screen.
(It is created only once during the first selection of SBOOK,
no matter how many times the second window is called).
  CALL METHOD custom_container1->free.
  IF not custom_container2 is initial.
    CALL METHOD custom_container2->free.
  ENDIF.
  CALL METHOD cl_gui_cfw=>flush.
  IF sy-subrc ne 0.
add your handling, for example
    CALL FUNCTION 'POPUP_TO_INFORM'
         EXPORTING
              titel = g_repid
              txt2  = sy-subrc
              txt1  = 'Error in Flush'(500).
  ENDIF.
  LEAVE PROGRAM.
ENDFORM.
*&      Module  PBO_100  OUTPUT
      text
MODULE pbo_100 OUTPUT.
  SET PF-STATUS 'MAIN100'.
  SET TITLEBAR 'MAIN100'.
  g_repid = sy-repid.
  IF custom_container1 is initial.
select data from table SFLIGHT
    PERFORM select_table_sflight CHANGING gt_sflight.
create a custom container control for our ALV Control
    CREATE OBJECT custom_container1
        EXPORTING
            container_name = cont_on_main
        EXCEPTIONS
            cntl_error = 1
            cntl_system_error = 2
            create_error = 3
            lifetime_error = 4
            lifetime_dynpro_dynpro_link = 5.
    IF sy-subrc ne 0.
add your handling, for example
      CALL FUNCTION 'POPUP_TO_INFORM'
           EXPORTING
                titel = g_repid
                txt2  = sy-subrc
                txt1  = 'The control could not be created'(510).
    ENDIF.
create an instance of alv control
    CREATE OBJECT grid1
           EXPORTING i_parent = custom_container1.
Set a titlebar for the grid control
    gs_layout-grid_title = 'Flights'(100).
allow to select multiple lines
    gs_layout-sel_mode = 'A'.
    CALL METHOD grid1->set_table_for_first_display
         EXPORTING i_structure_name = 'SFLIGHT'
                   is_layout        = gs_layout
         CHANGING  it_outtab        = gt_sflight.
->Create Object to receive events and link them to handler methods.
When the ALV Control raises the event for the specified instance
the corresponding method is automatically called.
    CREATE OBJECT event_receiver.
    SET HANDLER event_receiver->handle_user_command FOR grid1.
    SET HANDLER event_receiver->handle_toolbar FOR grid1.
§ 4.Call method 'set_toolbar_interactive' to raise event TOOLBAR.
    CALL METHOD grid1->set_toolbar_interactive.
  ENDIF.                               "IF grid1 IS INITIAL
  CALL METHOD cl_gui_control=>set_focus EXPORTING control = grid1.
ENDMODULE.                             " PBO_100  OUTPUT
*&      Module  PAI_100  INPUT
      text
MODULE pai_100 INPUT.
  CASE ok_code.
    WHEN 'EXIT'.
      PERFORM exit_program.
  ENDCASE.
  CLEAR ok_code.
ENDMODULE.                             " PAI_100  INPUT
*&      Module  PBO_0101  OUTPUT
      text
MODULE pbo_0101 OUTPUT.
  IF custom_container2 is initial.
(the data from sbook is already selected)
create a custom container control for our ALV Control
    CREATE OBJECT custom_container2
        EXPORTING
            container_name = cont_on_dialog
        EXCEPTIONS
            cntl_error = 1
            cntl_system_error = 2
            create_error = 3
            lifetime_error = 4
            lifetime_dynpro_dynpro_link = 5.
    IF sy-subrc ne 0.
add your handling, for example
      CALL FUNCTION 'POPUP_TO_INFORM'
           EXPORTING
                titel = g_repid
                txt2  = sy-subrc
                txt1  = 'The control could not be created'(510).
    ENDIF.
create an instance of alv control
    CREATE OBJECT grid2
           EXPORTING i_parent = custom_container2.
change title
    gs_layout-grid_title = 'Bookings'(101).
    gs_layout-sel_mode = ' '.
    CALL METHOD grid2->set_table_for_first_display
         EXPORTING i_structure_name = 'SBOOK'
                   is_layout        = gs_layout
         CHANGING  it_outtab        = gt_sbook.
  ELSE.
    CALL METHOD grid2->refresh_table_display.
  ENDIF.                               "IF custom_container2 IS INITIAL.
  CALL METHOD cl_gui_control=>set_focus EXPORTING control = grid2.
  CALL METHOD cl_gui_cfw=>flush.
  IF sy-subrc ne 0.
add your handling, for example
    CALL FUNCTION 'POPUP_TO_INFORM'
         EXPORTING
              titel = g_repid
              txt2  = sy-subrc
              txt1  = 'Error in Flush'(500).
  ENDIF.
ENDMODULE.                             " PBO_0101  OUTPUT
*&      Form  SELECT_TABLE_SFLIGHT
      text
     <--P_GT_SFLIGHT  text
FORM select_table_sflight CHANGING p_gt_sflight LIKE gt_sflight[].
  SELECT * FROM sflight INTO TABLE p_gt_sflight up to g_max rows.
ENDFORM.                               " SELECT_TABLE_SFLIGHT
*&      Form  SELECT_TABLE_SBOOK
      text
     -->P_LS_SFLIGHT  text
     <--P_GT_SBOOK  text
FORM select_table_sbook USING    p_ls_sflight LIKE LINE OF gt_sflight
                        CHANGING p_gt_sbook LIKE gt_sbook[].
  DATA: lt_sbook LIKE gt_sbook[].
Select data from sbook according to a line of sflight
and append that data to table p_gt_sbook
  SELECT * FROM  sbook INTO TABLE lt_sbook
         WHERE  carrid  = p_ls_sflight-carrid
         AND    connid  = p_ls_sflight-connid
         AND    fldate  = p_ls_sflight-fldate.
  APPEND LINES OF lt_sbook TO p_gt_sbook.
ENDFORM.                               " SELECT_TABLE_SBOOK
*&      Module  PAI_0101  INPUT
      text
MODULE pai_0101 INPUT.
  CASE ok_code.
    WHEN 'RETURN'.
      LEAVE TO SCREEN 0.
  ENDCASE.
  CLEAR ok_code.
ENDMODULE.                             " PAI_0101  INPUT
*&      Form  show_booking_table
      text
     -->P_ET_INDEX_ROWS  text
FORM show_booking_table TABLES p_et_index_rows
                                STRUCTURE lvc_s_row.
  DATA: ls_selected_line LIKE lvc_s_row,
        lf_row_index TYPE lvc_index,
        ls_sflight LIKE LINE OF gt_sflight.
  CLEAR gt_sbook[].
  LOOP AT p_et_index_rows INTO ls_selected_line.
    lf_row_index = ls_selected_line-index.
read selected row from internal table gt_sflight
    READ TABLE gt_sflight INDEX lf_row_index INTO ls_sflight.
select corresponding lines of table sbook
and append new lines to global table
    PERFORM select_table_sbook USING ls_sflight
                               CHANGING gt_sbook.
  ENDLOOP.
call dialog screen and display new alv control
  CALL SCREEN 101 STARTING AT 10 5.
ENDFORM.                               " show_booking_table
Regards,
Naveen.

Similar Messages

  • How to add push button in application tool bar in SAP transaction VA01

    How to add push button in application tool bar in SAP standard transaction VA01 and how to implement the code for that function code.

    There is no scope to create a push button in application tool bar. Instead of that we can add in a menu bar.

  • How to add custom buttons in the tool bar of the crystal reports viewer

    Hi,
    I'm using Crystal report viewer (Crystal 2008) in my report and I want to add custom buttons and handle them in the tool bar of the viewer. Is there anyway to achieve this?
    Please help me in this regard.
    Thanks in advance.
    Siva.

    I did this by adding a picturebox to the toolbar, the same size as the buttons, and loading in an image, and putting code into the Click event of the picturebox.
    I also put code into the MouseHover event to change the picture's background color and into the MouseLeave event to change it back.
    I have a couple of these buttons. They work very nicely and really look like part of the toolbar.

  • Open dialog box at the press of push button in alv tool bar

    Hi team,
    I have created alv report displaying field contents.mean while i have created one pushbutton in toolbar at the alv report output for downloading the  data into CSV Format.
    The requirement is ,At the push of the button, a standard download dialog box should open for download to local computer. The path and file name from the initial screen should be defaulted, but possible to update on the dialog box.
    please suggest me how to create download dialog box with field as file path where i can edit the defaulted file path.
    please let me know,how can i go ahead and satisfy the reuirement or share me piece of code if you have.
    Thanks And Regards,
    Sakti.

    After the user Command you can use
    * Display save dialog window
          CALL METHOD cl_gui_frontend_services=>file_save_dialog
            EXPORTING
    *      window_title      = ' Filenema'
              default_extension = 'TXT'
              default_file_name = 'data'
              initial_directory = 'c:\temp\'
            CHANGING
              filename          = ld_filename
              path              = ld_path
              fullpath          = ld_fullpath
              user_action       = ld_result.
          p_file  = ld_fullpath.

  • How to create a new push button in application tool bar in GMGRANT thru BDT

    Dear SAP Gurus -
    We have a requirement in 'GMGRANT' transaction. We need to create a button in the application tool bar of 'GMGRANT' transaction. Once the button is activated, if the user clicks on the button then it will go to a new screen (external screen). User can input data in to the external sceeen and upon saving, the data will be stored in to a custom table and when user clicks on 'back ' button user should come back to the GMGRANT transaction.
    Just wanted to know, how to create / activate a new button on application tool bar of GMGRANT transaction and what are the configuration and detail steps to achieve the same through BDT.
    We went through a lot of documents on BDT but do not have a proper solution.
    Could you please help.
    Thanks in advance.
    Regards,
    Atul Mohanty

    hi,
    You can find user-exits (menu exits) to add new menu item.
    But, there is no possibility to add new buttons on application tool bar.
    Regards,
    Sailaja.

  • Help on Button Choice of alv tool bar

    Hai , i created a button choice on the ALV tool bar .
    and now problem is how to capture the choices i.e how to check which choice is selected on the button?
    i defined an event handler methos with refernce to the event ON_FUNCTION of the alv.
    Please help me , its urgent,
    Madhuh

    Hi Madhuh,
    could you help me? I have a similar issue. It seems that you are one step ahead cause for me it is not possible to see the button choice in ALV.
    How did you set the button choice object to the ALV toolbar?
    I tried following:
      DATA: lr_interfacecontroller TYPE REF TO iwci_salv_wd_table,
            lr_alv_conf            TYPE REF TO cl_salv_wd_config_table,
            lr_func_settings       TYPE REF TO if_salv_wd_function_settings,
            lr_function            TYPE REF TO cl_salv_wd_function,
            lr_menu_action         TYPE REF TO cl_salv_wd_menu_action_item,
            lr_button_choice       TYPE REF TO cl_salv_wd_fe_button_choice,
    * create button choice
      CREATE OBJECT lr_button_choice.
    * function ID (need for field propeties?!)
      lr_function = lr_func_settings->create_function( 'BTN_CREATE_ETA' ).
    * set text
      lv_text = cl_wd_utilities=>get_otr_text_by_alias( '/SCMTMS/UI_COMMON/CREATE_ETA' ).
      lr_button_choice->set_text( lv_text ).
    * create menu objects for the categories depending on allowed categories:
      LOOP AT lt_value_set INTO ls_value_set.
        CONCATENATE 'CREATE_ETA' ls_value_set-key INTO lv_id.
        lv_text = ls_value_set-value.
    *   create menu action now
        CREATE OBJECT lr_menu_action
          EXPORTING
            id = lv_id.
        lr_menu_action->set_text( lv_text ).
    *   Add action menu to button choice
        lr_button_choice->add_choice( lr_menu_action ).
      ENDLOOP.
      lr_function->set_editor( lr_button_choice ).
    But that dumps in my case inside wd salv coding because of last statement. Is that the right way to do?
    Do you have a context mapping to the interface controller of ALV for that function? If yes how does it look like.
    Thanks in advance for your help!
    Regards Rico

  • How to add push button in alv display with out class or method

    Hai,
    How to add push buttons in out put screen of ALV (tool bar) with out using classes or methods .I want to know using normal ALV .
    Thanks in advance .
    kiran

    You should post your question in the ABAP forum.
    ABAP Development

  • Track add row button in alv

    Hello
    I would like to track the code of add row button in alv grid. When user cliks add row in avl toolbar what is the code? Is there some PAI module calls in that moment ? I found something about slis_selfield and something like mc_fc_loc_insert_row. I have tried write a code:
    data button type ui_func.
    button = gr_alvgrid -> mc_fc_loc_insert_row.
    After that, in PAI module of screen where alv is, I have tried to read that button. But no results.
    Frankly speaking I don't know how to use that all. Can anybody tell me how.
    I will be gratefully.

    Hi Sri,
    I think there is no standard way for this.
    Maybe with java script.
    Actually the users do not need to save data before they get the additional lines, A refresh is enough.
    So maybe you should just define a button calling the refresh command and just name the button different.
    regards
    Cornelia

  • ALV TOOL BAR BUTTONS NOT ENABLED IN TCODE FBL3N

    Hello All,
    We have currently switched from 4.7 to Ecc 6.0 and while executing
    tcode FBL3N in ALV tool bar all the buttons like Change document , mass
    change , select layout , save layout are disabled.
    These all buttons are active in 4.7 but in ecc 6.0 these buttons are
    totally disabled.
    I have checked all these buttons fcode status in se41 and all that are
    active.
    Kindly guide us how to go about it.
    Regards,
    Sunny

    Hi suny,
    there are some new authority-objects in ecc6.
    try SU53 after executing FBL3N.
    Perhaps you find Authotity-Problems.
    Regards, Dieter

  • I need to add push button to last extended price unit in sale order item B

    i need to add push button to field  last extended price unit in sale order item additional data B

    i need to add push button to field  last extended price unit in sale order item additional data B

  • ALV Tool Bar

    Hi,
    I'm developing a report in ALV  using object oriented ABAP. I want to hide some of the buttons in the tool bar.
    Can anyone pls help me on this?
    Thanks

    How to add button to ALV toolbar using REUSE_ALV_LIST_DISPLAY?
    In the program which calls ALV using REUSE_ALV_LIST_DISPLAY,
    I have to add a new button.
    I saw the demo program BCALV_GRID_08, which is written using ABAP-Controls.
    In that example, the button is added using TOOLBAR event of cl_gui_alv_grid.
    Could you help me to implement the same logic using REUSE_ALV_LIST_DISPLAY parameters.
    you should copy the 'STANDARD' GUI status from program SAPLKKBL using transaction SE90 >Programming SubObjects> Gui Status.
    Execute this transaction to get to next screen. select status using checkbox. click on GUI Status --> Copy.
    Enter your Z program name and the name you what for this status - you can keep it as 'STANDARD' to be simple.
    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...
    When you call 'REUSE_ALV_GRID_DISPLAY' make sure you pass it the new status name.
    an example of one of mine:
    call function 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_callback_program = 'ZSDBOLST_REPORT'
    i_callback_pf_status_set = 'STANDARD' <----
    i_callback_user_command = 'USER_COMMAND'
    i_structure_name = 'I_BOLACT'
    i_grid_title = 'BOL Action Report'(031)
    is_layout = gs_layout
    it_fieldcat = gt_fieldcat[]
    i_save = 'A'
    is_variant = v_variant
    TABLES
    t_outtab = i_bolact
    EXCEPTIONS
    program_error = 1
    others = 2.
    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.
    Could you advice what might have gone wrong ?
    As identified with the FM's help you can do the following.
    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.
    2). Create a form named like so:
    Code:
    Form Set_pf_status
    Notes: Called by FM REUSE_ALV_GRID_DISPLAY
    FORM set_pf_status USING rt_extab TYPE slis_t_extab.
      SET PF-STATUS 'ZSTANDARD'.
    ENDFORM. "Set_pf_status
    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'.
    3). Create the following report:
    Code:
    Form User_command
    Notes: Called by FM REUSE_ALV_GRID_DISPLAY
           Detects whether the icon/button for
           'Return Tag Deletion' has been pressed. If it has then
           detect whether any rows have been highlighted and then
           set the delete flag.
    FORM user_command USING r_ucomm     LIKE sy-ucomm
                            rs_selfield TYPE slis_selfield.
    DATA: li_count TYPE I.
    IF r_ucomm EQ '%DELETE'.
      LOOP AT %g00 WHERE mark EQ 'X'.
        ADD 1 TO li_count.
      ENDLOOP.
      IF li_count GT 0.
        gc_delete_flag = 'X'.
        r_ucomm = '&F03'. "Back arraow
      ELSE.
        MESSAGE W000 WITH 'Please highlight the rows to be deleted!'.
      ENDIF.
    ENDIF.
    ENDFORM.  "User_command
    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.
    Then when you call the ALV function you to specify the following extra details:
    Code:
        call function 'REUSE_ALV_GRID_DISPLAY'
             exporting  i_callback_program = gc_repid
                        I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
                        I_CALLBACK_USER_COMMAND  = 'USER_COMMAND'
                        i_grid_title       = lc_grid_title
                        is_layout          = lc_layout
                        it_fieldcat        = gt_fieldcat
                        it_sort            = sort
                        i_save             = l_save
                        is_reprep_id       = l_bbs_id
                        is_variant         = l_variant
             tables     t_outtab           = %g00
             exceptions program_error      = 1
                        others             = 2.
    The parameters in capitals are the extra ones that need to be added.

  • Reg : ALV tool bar

    Hi all,
    I am displaying data in ALV grid format by using the FM REUSE_ALV_GRID_DISPLAY.
    I have added a custom button to the standard ALV  display screen.
    when I execute the report I get the button which I have created but the standard ALV tool bar is not getting displayed.
    Can any one please suggest me how i can get the ALV tool bar and custom button together.
    thanks
    vijay

    Hi
    Adding Your Own Functions
    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 “toolbar” to add the button and the event “user_command” to implement the new function.
    In the method handling the “toolbar” event, we define a new button by filling a structure and appending it to the table attribute “mt_toolbar” of the object to whose reference we can reach via the parameter “e_object” of the event.
    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->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->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->mt_toolbar.
    ENDFORM .
    The fields of the structure we fill are as follows:
    Field
    Description
    FUNCTION
    The function code for the function
    BUTN_TYPE
    Button type that will be added to the toolbar. Available button types are:
    0
    Button (normal)
    1
    Menu and default button
    2
    Menu
    3
    Separator
    4
    Radio button
    5
    Checkbox
    6
    Menu entry
    ICON
    Icon for the button (optional)
    TEXT
    Text for the button (optional)
    QUICKINFO
    Quick info for the button (optional)
    DISABLED
    Adds the button as disabled
    Fields of structure to be filled to add a new function
    we are adding a separator line and two buttons one of which is a normal button whereas the other is a menu button. To handle a menu button which as added by choosing ‘1’ or ‘2’ as the button type, we must also implement some coding at the method handling the event “menu_button” to define functions as to be subentries. The functions of these subentries are also handled under the event “user_command”.
    FORM handle_menu_button USING i_object TYPE REF TO cl_ctmenu
    i_ucomm TYPE syucomm .
    CASE i_ucomm .
    WHEN 'EXCH' .
    CALL METHOD i_object->add_function
    EXPORTING
    fcode = 'EU'
    text = 'Euro' .
    CALL METHOD i_object->add_function
    EXPORTING
    fcode = 'TRL'
    text = 'Turkish Lira' .
    ENDCASE .
    ENDFORM. " handle_menu_button
    Adding two functions to be subentries for the menu button with function code ‘EXCH’
    Now, to implement what to be executed when our button is pressed or our subentry is selected we need to program our functions in the method handling the event “user_command”.
    Implementing functioning codes for new functions
    FORM handle_user_command USING i_ucomm TYPE syucomm .
    DATA lt_selected_rows TYPE lvc_t_roid .
    DATA ls_selected_row TYPE lvc_s_roid .
    CALL METHOD gr_alvgrid->get_selected_rows
    IMPORTING
    et_row_no = lt_selected_rows .
    READ TABLE lt_selected_rows INTO ls_selected_row INDEX 1 .
    IF sy-subrc ne 0 .
    MESSAGE s000(su) WITH 'Select a row!'(203) .
    ENDIF .
    CASE i_ucomm .
    WHEN 'CAR' .
    READ TABLE gt_list INDEX ls_selected_row-row_id .
    IF sy-subrc = 0 .
    CALL FUNCTION 'ZDISPLAY_CARRIER_INFO'
    EXPORTING carrid = gt_list-carrid
    EXCEPTIONS carrier_not_found = 1
    OTHERS = 2.
    IF sy-subrc NE 0 .
    *--Exception handling
    ENDIF .
    ENDIF .
    WHEN 'EU' .
    READ TABLE gt_list INDEX ls_selected_row-row_id .
    IF sy-subrc = 0 .
    CALL FUNCTION 'ZPOPUP_CONV_CURR_AND_DISPLAY'
    EXPORTING monun = 'EU'
    quant = gt_list-paymentsum.
    ENDIF .
    ENDCASE .
    ENDFORM .
    As you can see, we are using the method “get_selected_rows” to get which row is selected. Since the button with function ‘EXCH’ branches into subfunctions, we do not implement anything for it. Instead, we implement functional codes for subfunctions.
    After all, to make ALV show our additional buttons, we must call the method “set_toolbar_interactive” for the ALV Grid instance after the instance is created.
    e.g. CALL METHOD gr_alvgrid->set_toolbar_interactive .
    Regards
    Preeti
    <b>
    Reward if useful</b>

  • "Excluding" not working with PF status In ALV tool bar

    Hi all,
    I have 5 buttond in ALV tool bar out of which for every distinct logic only two buttons should be actually visible on toolbar.For this am using-
    SET PF-STATUS 'ZQACCAL'  EXCLUDING '&QE17''&QA13''&QE19' IMMEDIATELY.
    Problem is am still viewing excluded buttons (ie '&QE17''&QA13''&QE19' )also.
    Please tell me the solution for the same.
    Thank you.

    Hi,
    Use:-
    *FOR EXCLUDING STANDARD BUTTON FROM ALV TOOLBAR
    DATA : it_exclude TYPE slis_t_extab,
           wa_exclude TYPE slis_extab.
    *          FOR EXCLUDING STANDARD BUTTONS FROM ALV TOOLBAR
      wa_exclude-fcode = '&OUP'.
      APPEND wa_exclude TO it_exclude.
      CLEAR wa_exclude.
      wa_exclude-fcode = '&ODN'.
      APPEND wa_exclude TO it_exclude.
      CLEAR wa_exclude.
      wa_exclude-fcode = '&OAD'.
      APPEND wa_exclude TO it_exclude.
      CLEAR wa_exclude.
      wa_exclude-fcode = '&INFO'.
      APPEND wa_exclude TO it_exclude.
      CLEAR wa_exclude.
    "similarly append more function codes for standard buttons that needs to be excluded
    "you can get to know the func code for the button by enabling debugging at run time
    "and check valus for sy-ucomm and append it to it_exclude
    *          DISPLAY RECORDS IN ALV GRID
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
       i_callback_program                = sy-repid
       it_fieldcat                       = it_field
       it_excluding                      = it_exclude
    TABLES
       t_outtab                          = it_final
    EXCEPTIONS
       program_error                     = 1
       OTHERS                            = 2.
      IF sy-subrc <> 0.
      ENDIF.
    Hope this helps you.
    Regards,
    Tarun
    Edited by: Tarun Gambhir on Mar 6, 2009 5:06 PM

  • Add a Button in JFrame Title Bar

    How can I add a button in JFrame Title Bar. I want to put on more button for docking after the closing button in the title bar.

    if you use JFrame.setDefaultLookAndFeelDecorated(true) then you can do it by extending the JRootPaneUI class of the L&F (the default is the metal L&F). that is not a easy task but if you want take a look at BasicRootPaneUI, there you will have to point it to a new TitlePane which you will have to create. to load all this you must use the UIManager class. if you need more explaination try reading on look and feel and customizing it.

  • Creating button in standard tool bar

    Hi gurus,
    I hve to create  button in standard tool bar along with the existing icons and buttons, plz help
    how to suppres the fields other than screen table methods?
    reward asure
    with regards,
    thambe

    hi,
    if u using ALV then go to SE41.
    Give SAPLKKBL as program name and STANDARD_FULLSCREEN as status....
    now click on Copy Status and in that give ur program and status name into To.....
    now in REUSE_ALV_GRID_DISPLAY
    FORM display_list.
      g_f_repid = sy-repid.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program       = g_f_repid
          i_callback_user_command  = 'USER_COMMAND'
          i_callback_pf_status_set = 'SET_STAT'
          it_fieldcat              = g_t_fieldcat[]
          it_events                = g_t_events[]
        TABLES
          t_outtab                 = g_t_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.
    ENDFORM. " display_list
    FORM set_stat USING rt_extab TYPE slis_t_extab.
      SET PF-STATUS 'ZSTAT' EXCLUDING rt_extab.
    ENDFORM.                    "set_stat
    here my status name is ZSTAT which i gave in SE41...
    and in user_command form...
    FORM user_command USING u_comm LIKE sy-ucomm selfield TYPE slis_selfield.
      CASE u_comm.
        WHEN 'DET'.
        ........ur logic.........
      ENDCASE.
    ENDFORM.                    "user_command
    reward if usefull...

Maybe you are looking for

  • Indesign Cs5 Quiting Unexpectedly All the time! Please Help...

    I currently have a Mac Book Pro - Mac OSX 10.6.8 I have been running Indesign cs5 for the last year or so now absolutely fine however today it has just started quiting unexpectedly all of the time. I have un-installed and re-installed and it seemed t

  • Getting an error in E2E analysis

    Hi, In E2E analysis we are getting an error: The system you selected do not contain any software component currently supported by E2E Analysis. Thanks Shail

  • Can I sum a list of value pairs by one element of the pairs?

    OK, I got a very helpful pointer to working around the time function limitations in Numbers. Now what I have is a table that looks something like this (excerpt of course) 10/10/07 2:15 PM 0:30 0.50 $0.00 Design - Draft 10/11/07 9:30 AM 0:45 0.75 $0.0

  • Converting to OTF and emailing

    I am using the below code to convert a SAP output to OTF and then send in an email as an attachement.  The email, works and the attachement is added but when I try to open the pdf attachement I get an error saying the file can not open or must be dam

  • View of Exchane mails afyer ML upgrade.

    Have Anyone faced a probelm with exchange after upgrading to OS X 10.8 ? Each time i change the selection to different mail account I lose the view on all my mails !!