Once again, I had to deal with the ALV Grid and its default toolbar. Although the class CL_GUI_ALV_GRID is not offically released for customer use, there are varoius scenarios where you have no choice but to use the class anyhow.
When initializing the output with SET_TABLE_FOR_FIRST_DISPLAY, you can provide a list of function codes to disable parts or all of the default functions. The function codes are available as public constants of the class CL_GUI_ALV_GRID. Things get a little more complex because there are dependencies between some of the functions (disabling the printing function also disables the print preview) as well as some “virtual function codes” that disable an entire group of functions with a single entry. Finally, some of the functions depend on the state of the grid – if the grid is not editable, the editing functions are automatically excluded. If you’re interested in the details of this behaviour, take a look at the private method TOOLBAR_INIT – that’s where the magic happens.
While this pre-defined logic is a good starting point, you’ll frequently want to adjust the toolbar. For instance, just about everyone should know how to use the ALV grid by now, so for many applications, it’s not necessary to display the info button. Since I’m notoriously bad when it comes to remembering the function code constants that are used to disable the toolbar buttons, I’ve thrown together a small reference card. It contains the constants defined by CL_GUI_ALV_GRID and looks like this:
If you’re interested, you can grab the PDF file from my site (I can’t seem to append PDF files to a blog entry here). It doesn’t contain any ground-breaking innovative stuff, just a different view of the existing functions that should be far more intuitive than the default presentation.