ALV ARAÇ ÇUBUĞUNDAN BUTON ÇIKARMAK / EXCLUDE BUTTONS FROM TOOLBAR IN ALV


OOALV kullanırken araç çubuğundan butonları nasıl çıkaracağımızı öğrenelim.
( E : Let's learn at how to exclude buttons from the toolbar while using OOALV. )

⭐ Gerekli veri tanımlamaları ( E : Required data definitions  )

DATA : gs_exclude TYPE  ui_func,
             gt_exclude TYPE  ui_functions.


⭐ CL_GUI_ALV_GRID sınıfının özniteliklerinde 'MC' ile başlayan bazı öznitelikler vardır. Bu öznitelikler sabittir ve bir initial değere sahiptir. Bu initial değerler butonlara atanan fonksiyon kodunu (Fct Code) tutar. Çıkarmak istediğimiz butonların fonksiyon kodlarını aşağıdaki gibi bir tabloya ekleyelim.

( E : In the attributes of the CL_GUI_ALV_GRID class there are some attributes that start with 'MC'. These attributes are constant and have an initial value. These initial values ​​hold the function code (Fct Code) assigned to the buttons. Let's add the function codes of the buttons we want to remove to a table as follows. )


METHOD exclude_buttons.

    gs_exclude cl_gui_alv_grid=>mc_fc_info.
    APPEND gs_exclude TO gt_exclude.

    gs_exclude cl_gui_alv_grid=>mc_fc_views.
    APPEND gs_exclude TO gt_exclude.

    gs_exclude cl_gui_alv_grid=>mc_fc_subtot.
    APPEND gs_exclude TO gt_exclude.

    gs_exclude cl_gui_alv_grid=>mc_fc_graph.
    APPEND gs_exclude TO gt_exclude.

ENDMETHOD.





 Çıkarmak istediğimiz butonların niteliklerini içeren tabloyu 'SET_TABLE_FOR_FIRST_DISPLAY' fonksiyonunun 'it_toolbar_excluding' parametresine verelim.

( E : Let's give the table containing the attributes of the buttons we want to exclude to the 'it_toolbar_excluding' parameter of the 'SET_TABLE_FOR_FIRST_DISPLAY' function. )


METHOD show_alv.

    CALL METHOD grd->set_table_for_first_display
      EXPORTING
        i_save               'A'
        is_layout            gs_layout
        
it_toolbar_excluding = gt_exclude
      CHANGING
        it_outtab            gt_data[]
        it_fieldcatalog      gt_fcat.

  ENDMETHOD.

⭐ Son olarak ekranın pbo sunda display metodundan önce exclude metodunu çağıralım.

( E : Finally, let's call the exclude method before the display method in screen pbo.  )


MODULE status_0100 OUTPUT.

  SET PF-STATUS 'STATUS100'.
  SET TITLEBAR  'TTLBAR100'.

  IF go_custom_container IS INITIAL.
    go_data->create_container( ).
    go_data->set_fieldcatalog( ).
    go_data->set_layout( ).
    go_data->exclude_buttons( ).
    go_data->display_data( ).
  ELSE.

    CALL METHOD go_alv_grid->refresh_table_display.

  ENDIF.

ENDMODULE.


⭐ ALV toolbardan buton çıkarma ile ilgili demo programın kodlarını Github hesabımda paylaştım.

( E : I shared the codes of the demo program for excluding buttons from the ALV toolbar on my Github account. )

⭐ Bu yazımda değindiğim ALV toolbardan buton çıkarmaya dair kodlara ZDEV_R_EXCLUDE_BUTTONS programından erişebilirsiniz.

( E : You can access the codes for excluding buttons from the ALV toolbar, which I mentioned in this article, from the ZDEV_R_EXCLUDE_BUTTONS program. )

⭐ Demo programa ait ekran görüntüsü aşağıdaki gibidir. 

( E : The screenshot of the demo program is as follows. )



RESULT :

Before excluding



After excluding





NOTE:  

If we want to remove toolbar ;

    gs_layout-no_toolbar 'X'.



Teşekkürler 😊
Thank you 😊

Hilal KARAGÖZLÜ 

SAP ABAP Consultant


Yorumlar