Skip to Content
After seeing what we could do to change the look and feel, I started to play around with the BADI further. And you can actually do a lot with this. You can write methods which will fire for all the standard events of the grid. You can set the handler for specifc events that you want to handle as a part of the BADI. You can add custom buttons and write the code when the user presses the same. If you want to activate the toolbar you need to set the parameter I_TOOLBAR_MANAGER. CREATE OBJECT W_GRID EXPORTING * I_SHELLSTYLE = 0 * I_LIFETIME = I_PARENT = W_CUSTOM_CONTAINER * I_APPL_EVENTS = space * I_PARENTDBG = * I_APPLOGPARENT = * I_GRAPHICSPARENT = * I_NAME = I_GRID_ID = ‘Y_RAVI_GRID_XT’ I_TOOLBAR_MANAGER = ‘X’ I_OPTIMIZE_OUTPUT = ‘X’ EXCEPTIONS ERROR_CNTL_CREATE = 1 ERROR_CNTL_INIT = 2 ERROR_CNTL_LINK = 3 ERROR_DP_CREATE = 4 GRID_ID_INVALID = 5 OTHERS = 6 . IF SY-SUBRC <> 0. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. Once you do this go to the implementation of your BADI and find out which class is implementing the BADI. image The toolbar parameter Switches on 3-level toolbar management. As you can see from the screen shots below, the toolbar can be expanded the to the extent the user wants. You can also exclude the existing buttons by filling the internal table CT_TOOLBAR_EXCLUDING, which is one of the changing parameters of the BADI. image image image Following is the code that I have written for creating buttons on the toolbar and also handling the events for the same. Now, let us see how these methods (which should be linked to the event firing on the ALV) are created. If you see the class that is implementing the BADI interface, by default you will the methods inherited from the BADI. So, in this case they will be SET_TABLE_FOR_FIRST_DISPLAY and REFRESH_TABLE_DISPLAY. Also, you can notice the interface name is prefixed to the same. image Now, we need add more methods to this class. Go ahead add the methods that you want to implement. Here I have created two new methods MODIFY_TOOLBAR to add add / remove buttons and FUNC_TOOLBAR to respond to the events. image However, the trick is to make sure these event dependent methods. So, go to the details of this method and associate the event, which is nothing one of the standar events provided by the CL_GUI_ALV_GRID. image I have just written some dummy coding to make sure my methods are working. So, I am just showing a message here. image We will continue to explore this and find out more things that we can do.
To report this post you need to login first.

1 Comment

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

  1. Ravi,

    Nice Details. Thank you.

    Will these buttons appear on every ALV GRID display.  Can we make it specific to certain programs. 

    Also will this BADI call be made when using the function module REUSE_ALV_GRID_DISPLAY.



Leave a Reply