Skip to Content

In this blog I would like to talk about the class

CL_ALV_GRID_XT

which is an extension of the ALV grid class CL_GUI_ALV_GRID.This class provides the following additional functions

1.

A BADI

ALV_GRID_XT

is provided which can be used for customizing the ALV grid before displaying.

2.

Provides a toolbar management class

CL_ALV_GRID_TOOLBAR_MANAGER

for ALV toolbar administration.

3.

Output optimization (hide empty columns)
Using function module

ALV_OPTIMIZE_OUTPUT

In this blog I would like to demonstrate a small example implementing the BADI ALV_GRID_XT functionality of the ALV extension class.

1.Creating BADI Filter entry in table TALV_GRID

image

2. Implement the BADI ALV_GRID_XT IN SE19 transaction

A. Define the filter in the implementation

image

B. Define the implementing class

image

C. Class ZCL_BADI_EXT

image

-emphasize = ‘X’.

      WHEN OTHERS.

    ENDCASE.

  ENDLOOP.

*Change the layout

  cs_layout-zebra      = ‘X’.

  cs_layout-cwidth_opt = ‘X’.

ENDMETHOD.

METHOD on_toolbar .

  • In this method you can manipulate the toolbar that was provided

  • by the application that created the ALV grid, e.g. add your

  • own toolbar buttons

  •   Add application specific toolbar functions

  DATA: ls_tb TYPE stb_button.

  ls_tb-butn_type = 3.

  INSERT ls_tb INTO e_object->mt_toolbar INDEX 1.

  ls_tb-function  = ‘BUTTON1’.

  ls_tb-icon      =  icon_alert.

  ls_tb-quickinfo = ‘This is button 1’.

  ls_tb-butn_type = ‘0’.

  INSERT ls_tb INTO e_object->mt_toolbar INDEX 1.

  ls_tb-function  =  ‘BUTTON2’.

  ls_tb-icon      =  icon_bw_ra_setting_active.

  ls_tb-quickinfo = ‘This is button2’.

  ls_tb-butn_type = ‘0’.

  INSERT ls_tb INTO e_object->mt_toolbar INDEX 1.

  ls_tb-function  =  ‘BUTTON3’.

  ls_tb-icon      =  icon_close.

  ls_tb-quickinfo = ‘This is button3’.

  ls_tb-butn_type = ‘0’.

  APPEND ls_tb TO e_object->mt_toolbar.

ENDMETHOD.                    “ON_TOOLBAR

METHOD on_user_command .

  • In this method you can handle the function codes of toolbar buttons

  • that were added in the on_toolbar method

  CASE e_ucomm.

    WHEN ‘BUTTON1’.

      MESSAGE i000(0k) WITH ‘This is “ALERT” for fcode’ e_ucomm.

    WHEN ‘BUTTON2’.

      MESSAGE i000(0k) WITH ‘This is “SETTING” for fcode’ e_ucomm.

    WHEN ‘BUTTON3’.

      MESSAGE i000(0k) WITH ‘This is “CLOSE” for fcode’ e_ucomm.

  ENDCASE.

ENDMETHOD.

Test program using the CL_ALV_GRID_XT Class

image

Additional Information

These additional functions are activated by the following parameters defined in the constructor of this class :

• I_GRID_ID

An entry from the TALV_GRID table is expected here. If this entry exists, then before executing the SET_TABLE_FOR_FIRST_DISPLAY or REFRESH_TABLE_DISPLAY methods, those methods from BADI ALV_GRID_XT that have the same names are called up.

• I_TOOLBAR_MANAGER

‘X’ = Switches on 3-level toolbar management

• I_OPTIMIZE_OUTPUT

‘X’ = Switches on display optimization, using the ALV_OPTIMIZE_OUTPUT function module.

To report this post you need to login first.

4 Comments

You must be Logged on to comment or reply to a post.

Leave a Reply