Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ALV tool bar

Former Member
0 Likes
4,692

Good day every one

I need some one to solve this issue for me ... i create multiple ALV grid in different containerswith splitters between each grid but 2 of the containers should include a customized buttons which I cant create external buttons im tryin to hide the ALV tool bar but i need to show my customized buttons as in the below pic :

http://img105.herosh.com/2011/10/15/799275730.jpg

And Certainly the below code will work ...

it_layout-NO_TOOLBAR = 'X'.

help experts

Edited by: SaraMaan on Oct 15, 2011 7:39 AM

Good day every one

I need some one to solve this issue for me ... i create multiple ALV grid in different containerswith splitters between each grid but 2 of the containers should include a customized buttons which I cant create external buttons im tryin to hide the ALV tool bar but i need to show my customized buttons as in the below pic :

http://img105.herosh.com/2011/10/15/799275730.jpg

And Certainly the below code will work ...

it_layout-NO_TOOLBAR = 'X'.

help experts

Edited by: SaraMaan on Oct 15, 2011 7:39 AM

13 REPLIES 13
Read only

Clemenss
Active Contributor
0 Likes
3,372

Hi SaraMaan,

I don not see the problem: Each toolbar of each ALV grid can be enhanced individually. If you don not want to do sol, you can further split the ALV container and put an additional toolbar on top or bottom of the ALV.

Code depends on ALV technique used - same as always: No code from you, no code from me.

Reagards

Clemens

Read only

0 Likes
3,372

Hi,

> Code depends on ALV technique used - same as always: No code from you, no code from me.

Yes, exactly, be careful in your next threads! By a search on the NO_TOOLBAR component, I deduce that it must be a direct use of CL_GUI_ALV_GRID class.


DATA ls_layout type LVC_S_LAYO.
ls_layout-no_toolbar = 'X'.
call method lo_alv_grid->SET_TABLE_FOR_FIRST_DISPLAY
    exporting
* ...
      IS_LAYOUT = ls_layout

I recommend you to run BCALV_TEST_GRID_TOOLBAR demo program, to see all the toolbar features.

Sandra

Read only

Former Member
0 Likes
3,372

Hi,

If I understood you correctly, you need to show only one button which was your custom button.

As an option you could disabled all buttons by excluding them from the toolbar and that you could do with just passing the table of excluded buttons



data: ls_exclude type ui_func,
         lt_exclude type ui_functions.

ls_exclude = cl_gui_alv_grid=>mc_fc_maximum.
append ls_exclude to lt_exclude.

you can then pass the table to the interface of alv method.

Read only

Former Member
0 Likes
3,372

Thanks guys but still all of the above methods are not working ...

Read only

0 Likes
3,372

I don't understand what you say, as :

1) you didn't confirm if it's CL_GUI_ALV_GRID or not, and you didn't paste your code as Clemens asked you

2) if it's CL_GUI_ALV_GRID, then BCALV_TEST_GRID_TOOLBAR shows how to do it, by clicking the "hide toolbar", it removes the whole standard toolbar, except the custom button "toggle change/display" (debug the program to see what are the statements after "hide toolbar" has been clicked)

Sandra

Read only

Former Member
0 Likes
3,372

THE CODE as below and it cl_gui_alv_grid. :

-


  • ALV controls

DATA Alv_1 TYPE REF TO cl_gui_alv_grid.

.

  • load control framework definition

data : it_layout TYPE lvc_s_layo,

it_layout2 TYPE lvc_s_layo,

it_fcat TYPE lvc_t_fcat,

it_fcat2 TYPE lvc_t_fcat.

data: ls_exclude type ui_func,

gs_variant TYPE disvariant,

lt_exclude type ui_functions.

TYPE-POOLS cndp.

DATA init.

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

*===============================================================

****************************************************************

  • LOCAL CLASSES: Implementation

****************************************************************

*===============================================================

  • class lcl_event_receiver (Implementation)

CLASS lcl_event_receiver IMPLEMENTATION.

METHOD handle_toolbar.

  • by using event parameter E_OBJECT.

DATA: ls_toolbar TYPE stb_button.

  • 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 'AIRCRAFT LIST' TO ls_toolbar-function.

MOVE ICON_BW_REF_STRUCTURE_SAP TO ls_toolbar-icon.

MOVE 'Show Tail No. and Equipment'(111) TO ls_toolbar-quickinfo.

MOVE 'Structure'(112) TO ls_toolbar-text.

MOVE '' TO ls_toolbar-disabled.

APPEND ls_toolbar TO e_object->mt_toolbar.

ENDMETHOD.

  • ALV output :

                                          • here where I tried to exclude some of the toolbar buttons *********************

ls_exclude = cl_gui_alv_grid=>mc_fc_loc_append_row .

APPEND ls_exclude TO lt_exclude.

ls_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row .

APPEND ls_exclude TO lt_exclude.

ls_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row .

APPEND ls_exclude TO lt_exclude.

ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy .

APPEND ls_exclude TO lt_exclude.

ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy_row .

APPEND ls_exclude TO lt_exclude.

CALL METHOD alv_1->set_table_for_first_display

EXPORTING

is_layout = it_layout

it_toolbar_excluding = lt_exclude

is_variant = gs_variant

  • i_save =

  • is_print =

CHANGING

it_outtab = INT_FLEET

it_fieldcatalog = it_fcat

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

OTHERS = 4.

cREATE OBJECT event_receiver.

SET HANDLER event_receiver->handle_user_command FOR alv_1.

SET HANDLER event_receiver->handle_toolbar FOR alv_1.

CALL METHOD alv_1->set_toolbar_interactive.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

END-OF-DEFINITION.

Edited by: SaraMaan on Oct 16, 2011 9:55 AM

Read only

0 Likes
3,372

Thanks.

It seems your code is correct : you hide a few standard buttons (didn't you want to hide all, i.e. using cl_gui_alv_grid=>mc_fc_excl_all ?), then you add your custom buttons using event toolbar.

I suspect the issue is because you call set_toolbar_interactive method, that would reset the standard toolbar, thus ignoring your previous commands.

Sandra

Read only

0 Likes
3,372

Hi,

something is wrong or incomplete with your code. There is not

DATA event_receiver.TYPE REF TO lcl_event_receiver

at least I could not find it in your mal-formatted code (Please use code tags!).

The call alv_1->set_toolbar_interactive( ) is missing. This call will raise the event TOOLBAR. Your method handle_toolbar must be defined as a handler for this, i.e.

methods HANDLE_TOOLBAR
    for event TOOLBAR of CL_GUI_ALV_GRID

Your current code should give syntax or runtime errors, at least sy-subrc NE 0 for set handler..

Regards

Clemens

Read only

0 Likes
3,372

> The call alv_1->set_toolbar_interactive( ) is missing. This call will raise the event TOOLBAR.

Hi Clemens,

I just said the opposite :-p. I used the example from the BCALV_TEST_GRID_TOOLBAR program which doesn't use SET_TOOLBAR_INTERACTIVE, nethertheless, the toolbar event is automatically triggered. Well, I did a few more tests, and I could see that it is not raised when IS_LAYOUT-NO_TOOLBAR is set to 'X'. In that case, the method SET_TOOLBAR_INTERACTIVE can be used.

Sandra

Read only

0 Likes
3,372

thanks guys but i already made the call in the code

methods HANDLE_TOOLBAR

for event TOOLBAR of CL_GUI_ALV_GRID

there is something missing the the code :"(

Read only

0 Likes
3,372

THANKS all I i did it

its working now I did the code below in the METHOD handle_toolbar after append :

READ TABLE E_OBJECT->MT_TOOLBAR INTO LS_TOOLBAR INDEX 1.

DELETE E_OBJECT->MT_TOOLBAR WHERE FUNCTION = '&DETAIL'.

Read only

0 Likes
3,372

Hi,

that's great for you, but it's absolutely not your initial requirement.

Here, you remove the "details" button, but you wanted to remove all buttons.

So, I need to explain to other folks that might look for the same question as yours.

To remove all buttons, you don't need to delete in the toolbar event handler, you just have to add this statement before calling method SET_ALV_FOR_FIRST_DISPLAY.


    ls_exclude = cl_gui_alv_grid=>MC_FC_EXCL_ALL. "remove all buttons
    APPEND ls_exclude TO lt_exclude.
    CALL METHOD alv_1->set_table_for_first_display
      EXPORTING
...
        it_toolbar_excluding          = lt_exclude

Now the activatable, and immediately functional code is


DATA INT_FLEET TYPE TABLE OF sflight.
DATA alv_1 TYPE REF TO cl_gui_alv_grid.
*----------------------------------------------------------------------*
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
DATA event_receiver TYPE REF TO lcl_event_receiver.
*----------------------------------------------------------------------*
CLASS lcl_event_receiver IMPLEMENTATION.

  METHOD handle_toolbar.
* by using event parameter E_OBJECT.
    DATA: ls_toolbar TYPE stb_button.
*  DELETE E_OBJECT->MT_TOOLBAR WHERE FUNCTION = '&DETAIL'.
* 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 'AIRCRAFT LIST' TO ls_toolbar-function.
    MOVE icon_bw_ref_structure_sap TO ls_toolbar-icon.
    MOVE 'Show Tail No. and Equipment'(111) TO ls_toolbar-quickinfo.
    MOVE 'Structure'(112) TO ls_toolbar-text.
    MOVE '' TO ls_toolbar-disabled.
    APPEND ls_toolbar TO e_object->mt_toolbar.
  ENDMETHOD.                    "handle_toolbar
ENDCLASS.                    "lcl_event_receiver IMPLEMENTATION

AT SELECTION-SCREEN OUTPUT.
  IF alv_1 IS INITIAL.
    SELECT * FROM sflight INTO TABLE INT_FLEET.
* load control framework definition
    DATA: it_layout TYPE lvc_s_layo,
          it_fcat TYPE lvc_t_fcat,
          ls_exclude TYPE ui_func,
          gs_variant TYPE disvariant,
          lt_exclude TYPE ui_functions.
* ALV output :
********************* here where I tried to exclude some of the toolbar buttons *********************
    ls_exclude = cl_gui_alv_grid=>MC_FC_EXCL_ALL.
    APPEND ls_exclude TO lt_exclude.

    PERFORM get_fcat CHANGING INT_FLEET it_fcat.
    create object alv_1 exporting i_parent = cl_gui_container=>screen0.
    CREATE OBJECT event_receiver.
* set the toolbar handler before SET_TABLE_FOR_FIRST_DISPLAY so that to
* make it raised automatically (thus no need to call SET_TOOLBAR_INTERACTIVE)
    SET HANDLER event_receiver->handle_toolbar FOR alv_1.
    CALL METHOD alv_1->set_table_for_first_display
      EXPORTING
        is_layout                     = it_layout
        it_toolbar_excluding          = lt_exclude
        is_variant                    = gs_variant
      CHANGING
        it_outtab                     = INT_FLEET
        it_fieldcatalog               = it_fcat
      EXCEPTIONS
        invalid_parameter_combination = 1
        program_error                 = 2
        too_many_lines                = 3
        OTHERS                        = 4.
*    CALL METHOD alv_1->set_toolbar_interactive.
  endif.
*---------------------------------------------------------------------------
FORM get_fcat CHANGING it_std TYPE STANDARD TABLE et_fcat TYPE lvc_t_fcat.
  DATA lo_table TYPE REF TO cl_salv_table.
  DATA lo_columns TYPE REF TO cl_salv_columns_list.
  DATA lo_agg TYPE REF TO cl_salv_aggregations.
  REFRESH et_fcat.
  CALL METHOD cl_salv_table=>factory
    IMPORTING
      r_salv_table = lo_table
    CHANGING
      t_table      = it_std[].
  lo_columns = lo_table->get_columns( ).
  lo_agg = lo_table->get_aggregations( ).
  et_fcat = cl_salv_controller_metadata=>get_lvc_fieldcatalog( r_columns = lo_columns r_aggregations = lo_agg ).
ENDFORM.

sandra

Read only

0 Likes
3,372

I used the example from the BCALV_TEST_GRID_TOOLBAR program which doesn't use SET_TOOLBAR_INTERACTIVE, nethertheless, the toolbar event is automatically triggered. Well, I did a few more tests, and I could see that it is not raised when IS_LAYOUT-NO_TOOLBAR is set to 'X'. In that case, the method SET_TOOLBAR_INTERACTIVE can be used.

One precision: SET_TOOLBAR_INTERACTIVE is not needed if we place the SET HANDLER toolbar before the call to SET_TABLE_FOR_FIRST_DISPLAY, as this latter method raises the toolbar event.

Sandra