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.

Similar Messages

  • "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

  • 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

  • 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

  • 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>

  • ALV tool bar settings

    Hi,
    How and where to see ALV tool bar settings? in FPM environment?what is the method/class?
    the requirement is to enable /disble  few ALV settings  like, 'Filter'...'settings'...'View(drop down)'on top of ALV tool bar

    Hi,
    You can use the following for doing different settings for an alv:
    data: lr_alv_usage type ref to if_wd_component_usage,
            lr_if_controller type ref to iwci_salv_wd_table,
            lr_table_settings type ref to if_salv_wd_table_settings,
            lr_table type ref to cl_salv_wd_config_table,
            lr_column_settings type ref to if_salv_wd_column_settings,
            lr_column  type ref to cl_salv_wd_column,
            lt_columns type salv_wd_t_column_ref,
            ls_columns type salv_wd_s_column_ref,
            lr_col_header type ref to cl_salv_wd_column_header,
            lr_link type ref to cl_salv_wd_uie_link_to_action,
            lr_check_box type ref to cl_salv_wd_uie_checkbox,
            lr_image type ref to cl_salv_wd_uie_image,
            lr_input_field type ref to cl_salv_wd_uie_input_field.
      data: lr_function_settings type ref to if_salv_wd_function_settings,
            lr_standard_functions type ref to if_salv_wd_std_functions,
            lr_user_function type ref to cl_salv_wd_function,
            lr_drdn type ref to cl_salv_wd_uie_dropdown_by_idx,
            lr_add_button type ref to cl_salv_wd_fe_button.
    Control field
      data: lr_field_settings type ref to if_salv_wd_field_settings,
            lr_field          type ref to cl_salv_wd_field,
            lr_sort_rule      type ref to cl_salv_wd_sort_rule,
            lr_aggr_rule      type ref to cl_salv_wd_aggr_rule.
    These are some classes and interfaces that you can use. We have methods in them that will help to do settings .
    For further details plz check the link:
    http://help.sap.com/saphelp_nw04s/helpdata/en/7f/849e6d796d4fe49221609ffcbc357d/content.htm
    Thanks And Regards,
    NSingh
    Edited by: Nsingh on Feb 23, 2012 8:52 AM

  • ALV tool bar functionality

    Hi
      I want to know is the following functionality are present in the tool bar of ALV grid :
            Details View
            Sorting : Ascend Desending
           Filter
           Totalling Subtotalling
           Print Preview
           Microsoft Excel View
          Word Processing
          Local File download
          SAP email
          ABC analysis
          Graphic View
         Change Layout
         Information

    Hi,
    if u create an alv grid.
    u will get all the followintg functionalities by default.
    rgds,
    bharat.

  • 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.

  • 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.

  • How to activate sumation functions in alv tool bar..!!

    hi,
    how to activate the icon for summation that appears for an alv when it is in diasabled State.
    all icons are working except that summation...please suggest me..!
    thanks
    sivaram.

    Hi,
    In your ALV there has to be numerical field. Check the structure.
    It wiill come automatically.
    Reward if useful!

  • Hiding parts of the tool bar

    In the ALV grid using OOPS , I want to hide some tools of the tool bar. I knwo I must pass a table to the fist display . But from where do I get to know the names of the tools , I mean which table.
    Right now i want to hide all components except the sort and the print.
    Thank you

    Hi,
    In an internal table populate all the ALV Tool bar ICON names which you want to Hide and pass it to IT_EXCLUDE_TOOLBAR in the ALV call Method.
    data : it_toolbar type ui_functions, "Used for Toolbar addition
    wa_toolbar like line of it_toolbar."Used in form Exclude_Toolbar
    wa_toolbar = cl_grid->MC_FC_LOC_APPEND_ROW.
    append wa_toolbar to it_toolbar.
    wa_toolbar = cl_grid-mc_fc_loc_paste. "Toolbar Button PASTE OVER ROW
    append wa_toolbar to it_toolbar.
    wa_toolbar = cl_grid-mc_fc_loc_paste_new_row. "Toolbar Button PASTE NEW ROW
    append wa_toolbar to it_toolbar.
    wa_toolbar = cl_grid->mc_fc_find. "Toolbar Button FIND
    append wa_toolbar to it_toolbar.
    CALL METHOD cl_grid->set_table_for_first_display
    EXPORTING
    IT_TOOLBAR_EXCLUDING = it_toolbar
    CHANGING
    it_outtab = it_sflight[]
    IT_FIELDCATALOG = g_fieldcat.
    ONEMORE SAMPLE CODE.....
    PEFORM EXCLUDE_TOOLBAR.
    CALL METHOD grid1->set_table_for_first_display
    EXPORTING
    i_structure_name = 'ZFLP_STCUALCONDPRI'
    is_layout = gs_layout
    i_save = 'A'
    IT_TOOLBAR_EXCLUDING = it_toolbar1
    CHANGING
    it_outtab = gt_zflp_ttcualcond
    it_fieldcatalog = gt_fieldcat.
    My code for buttons..
    FORM EXCLUDE_TOOLBAR.
    data : it_toolbar1 type standard table of ui_functions,
    wa_toolbar like line of it_toolbar.
    You need to specify the Methods of the ALV ICONS which are not required.
    THis code will Grade out PASE and Find buttons.
    Similarly you can pass the name of icons which are not required to this internal table
    and append it.
    wa_toolbar = cl_grid-mc_fc_loc_paste. "Button PASTE append wa_toolbar to it_toolbar1.
    wa_toolbar = cl_grid->mc_fc_find. "Button FIND
    append wa_toolbar to it_toolbar1.
    ENDFORM.
    CLASS lcl_event_receiver IMPLEMENTATION.
    *handle tool bar methods..
    METHOD handle_toolbar.
    *variables for the toolbar
    DATA lt_toolbar TYPE ttb_button.
    DATA ls_mttoolbar TYPE LINE OF ttb_button.
    User command toolbar buttons..
    ls_mttoolbar-function = 'add_row'.
    ls_mttoolbar-icon = '@17@'.
    ls_mttoolbar-quickinfo = 'Add a new row'.
    ls_mttoolbar-text = 'Add node'.
    ls_mttoolbar-butn_type = '0'.
    APPEND ls_mttoolbar TO lt_toolbar.
    e_object->mt_toolbar = lt_toolbar.
    ls_mttoolbar-function = 'del_row'.
    ls_mttoolbar-icon = '@18@'.
    ls_mttoolbar-quickinfo = 'Delete a row'.
    ls_mttoolbar-text = 'Delete node'.
    ls_mttoolbar-butn_type = '5'.
    APPEND ls_mttoolbar TO lt_toolbar.
    e_object->mt_toolbar = lt_toolbar.
    ls_mttoolbar-function = 'save_data'.
    ls_mttoolbar-icon = '@2L@'.
    ls_mttoolbar-quickinfo = 'Save the current data'.
    ls_mttoolbar-text = 'save data'.
    ls_mttoolbar-butn_type = '5'.
    APPEND ls_mttoolbar TO lt_toolbar.
    e_object->mt_toolbar = lt_toolbar.
    ENDMETHOD. "handle_toolbar
    REGARDS
    VASU

  • To disable the Application tool bar button in ALV report

    Hi Everyone,
    Iam using REUSE_ALV_GRID_DISPLAY to display ALV report.
    Now my requirement is to disable(I mean grey out) a application tool bar button.
    Thanks in advance
    Moderator message: please search for available information and try yourself before asking.
    locked by: Thomas Zloch on Sep 23, 2010 11:38 AM

    We can disable the buttons on the application toolbar as below.
    *To Exclude a few buttons from the Application tool bar
    data: it_excluding type slis_t_extab.
    data: wa_excluding type slis_extab.
    wa_excluding-fcode = '&OUP'.
    append wa_excluding to it_excluding.
    wa_excluding-fcode = '&ILT'.
    append wa_excluding to it_excluding.
    wa_excluding-fcode = '&ODN'.
    append wa_excluding to it_excluding.
    and in the FM.....
    call function 'REUSE_ALV_GRID_DISPLAY'
          exporting
            i_callback_program      = sy-repid
            i_callback_pf_status_set = 'ZPICK'
            is_layout               = itlayout
            i_callback_user_command =  'LIST1'
            i_grid_title            = <fs>
    *       i_callback_top_of_page  = ' '
            it_fieldcat             = itfieldcat[]
            it_excluding            = it_excluding
    But,no idea on how to disable the  whole application tool bar itself ?
    K.Kiran.

  • ALV GRID Tool bar options not working

    Hello Experts,
    I copied the standard tool bar into my program with the name 'ZSALV_STANDARD' and displaying the output in the grid format in a container with the method set_table_for_first_display
    When I execute the program the standard buttong in the tool bar are not working... Can anyone guide where am I going wrong...
    Here is my code
    DATA :    gr_event_handler TYPE REF TO lcl_event_handler .
      DATA:  threed TYPE i VALUE 1.
      SET PF-STATUS  'ZSALV_STANDARD'.
    * Creating an instance for the event handler
      CREATE OBJECT gr_event_handler .
      TRY.
          CREATE DATA i_table TYPE TABLE OF (viewname).
          ASSIGN i_table->* TO <i_itab>.
          CREATE DATA wa_all LIKE LINE OF <i_itab>.
          ASSIGN wa_all->* TO <wa_tab>.
    *     Selecting data dynamically
          SELECT * FROM (viewname) INTO TABLE <i_itab>.
    *     Building the fieldcatelog
          CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
            EXPORTING
              i_structure_name       = viewname
            CHANGING
              ct_fieldcat            = li_fieldcat
            EXCEPTIONS
              inconsistent_interface = 1
              program_error          = 2
              OTHERS                 = 3.
          IF sy-subrc <> 0.
            MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
          ENDIF.
    *     Making fields editable except key fields
          IF sy-ucomm = 'UPD' OR  sy-ucomm = 'CHANGE'.
            LOOP AT li_fieldcat INTO lwa_fieldcat.
              IF lwa_fieldcat-key = space.
                lwa_fieldcat-edit = 'X'.
                MODIFY li_fieldcat FROM lwa_fieldcat.
              ENDIF.
            ENDLOOP.
          ENDIF.
    *     Making fields editable
          IF sy-ucomm = 'NEW'.
            LOOP AT li_fieldcat INTO lwa_fieldcat.
              lwa_fieldcat-edit = 'X'.
              MODIFY li_fieldcat FROM lwa_fieldcat.
            ENDLOOP.
            lh_flag = 'X'.
            CLEAR : <i_itab>.
            DO 100 TIMES.
              APPEND <wa_tab> TO <i_itab>.
            ENDDO.
          ENDIF.
    *     Exclude buttons
          PERFORM exclude_tb_functions CHANGING i_exclude.
          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.
          ENDIF.
    *     Making all fields non-editable if display mode
          IF sy-ucomm = 'SHOW'.
            LOOP AT li_fieldcat INTO lwa_fieldcat.
              lwa_fieldcat-edit = ' '.
              MODIFY li_fieldcat FROM lwa_fieldcat.
            ENDLOOP.
          ENDIF.
          IF sy-ucomm = 'SAVE'.
            LOOP AT li_fieldcat INTO lwa_fieldcat.
              IF lwa_fieldcat-key NE space.
                lwa_fieldcat-edit = space.
                MODIFY li_fieldcat FROM lwa_fieldcat.
              ENDIF.
            ENDLOOP.
          ENDIF.
    *     Displaying ALV Grid
          i_layout-NO_TOOLBAR = 'X'.
          i_layout-edit = 'X'.
          CALL METHOD grid1->set_table_for_first_display
            EXPORTING
              i_structure_name              = viewname
              it_toolbar_excluding          = i_exclude
              i_default                     = 'X'
              is_layout                     = i_layout
            CHANGING
              it_outtab                     = <i_itab>
              it_fieldcatalog               = li_fieldcat
            EXCEPTIONS
              invalid_parameter_combination = 1
              program_error                 = 2
              too_many_lines                = 3.
          IF sy-subrc NE 0.
            EXIT.
          ENDIF.
    *      Getting the changed data
          SET HANDLER gr_event_handler->handle_data_changed FOR grid1 .
        CATCH cx_sy_create_data_error.
      ENDTRY.
    Thanks alot in advance.
    Sri

    Hello ,
    try
        call method g_grid%->set_table_for_first_display
          exporting
            i_save               = p_save_layout%
            i_default            = 'X'
            is_layout            = ps_layout%
            is_variant           = ps_variant%
            it_toolbar_excluding = pt_exclude%
          changing
            it_outtab            = pt_alv_tab1[]
            it_fieldcatalog      = pt_fieldcat%[].
        call method g_grid%->set_toolbar_interactive.
    regards
    Prabhu

  • Re: ALV Grid Application Tool Bar

    Dear Experts,
                 I am displaying a report in ALV grid. In the application tool bar. 'save layout' and 'change layout' icons were missing.if i want to put those icons on application tool bar where i have to change? if anybody knows pls. help on this.
    Thanks in advance.
    Thanks and regards,
    Harish babu

    Hello Harish
    The parameter I_SAVE (of method SET_TABLE_FOR_FIRST_DISPLAY) can have several setting(<a href="http://help.sap.com/saphelp_erp2005vp/helpdata/en/bf/3bd1369f2d280ee10000009b38f889/content.htm">ALV Grid Control</a>):
    I_SAVE
    Determines the options available to the user for saving a layout:
    'X':         global saving only
    'U':         user-specific saving only
    'A':         corresponds to 'X' and 'U'
    SPACE:       no saving
    In addition, you have to provide parameter IS_VARIANT:
    IS_VARIANT
    Determines the layout to be used for displaying the output table. If you use this parameter, you must at least fill field REPORT of the structure of type DISVARIANT
    Regards
      Uwe

  • Problem with refresh button in tool bar in ALV

    hello experts,
                              I am displaying a report using OOPS ALV. Here i am deleting one row. After deleting the row, if i clicked on REFRESH button in the tool bar, it should display the table newly with all updations which i made. wat is the code to perform dis.
                                                      thanks in adance,

    in normal ALV we can refresh using     sel-refresh = 'X'.
    in OOPS ALV
    IF wa_toolbar-function = '&REFRESH'.
            wa_toolbar-function = 'REFRESH'.
            wa_toolbar-disabled = gc_x.
            MODIFY e_object->mt_toolbar FROM wa_toolbar
                              TRANSPORTING function disabled.

Maybe you are looking for