The ALV Grid Control
The ALV Grid Control is a tool that you can use to display non-hierarchical lists in a standardized form. The list data displays in tables. It is easy to work with the tool, as there are very few programming steps that must be carried out.
The ALV Grid Control contains a number of interactive standard functions that users of lists often need, for example, print, export. As a developer, you have the option of hiding these standard functions. When required, you can adapt the implementations to fit the needs of your application. You can also add your own functions to the application toolbar.
The following topics illustrate the possible application areas of object-oriented ABAP programming and the use of SAP standard classes. For example, ALV Grid Control in the context of the Control Framework and the Business Add-Ins (BAdIs).
The SAP Control Framework is a collection of global classes and interfaces that you can use to add SAP GUI controls in your ABAP Objects programs, regardless of the platform.
Including an ALV Grid Control Instance in a Dialog Program
Container Controls provide the technical connection between the screen and application controls. The application controls ALV Grid Control, Tree Control, and Picture Control are always embedded in the Container Control, which is connected to the screen.
There are different types of container controls. However, all incorporate fundamental control functions, such as scroll bars.
Creation of an ALV
You must place an ALV Grid Control in a screen area with a fixed size. To do this, you must create an instance of each of the global classes CL_GUI_CUSTOM_CONTAINER and CL_GUI_ALV_GRID.
For normal display, perform the following programming steps:
If the table has a global row type defined in ABAP Dictionary, you can transfer the name of this global structure to the same method. The ALV Grid Control creates the field catalog automatically.
The internal table transferred to the method SET_TABLE_FOR_FIRST_DISPLAY must be globally defined. Therefore, the table must be either a global program variable or a public attribute of a class.
When you change the contents of the internal tables while the program is running, you only need to call the method REFRESH_TABLE_DISPLAY in the relevant dialog step to refresh the display.
Implementation of a Handler for the Double-Click Event
An ALV Grid Control can react to the user’s double-click. As a possible reaction, you can trigger a follow-on processing step in which additional information is displayed.
In the example shown in the figure, the booking data for the individual flight customers or data on the aircraft, can also be displayed for the flight data. This is executed by catching the event DOUBLE_CLICK with a handler method.
ALV Grid Control – Reacting to a Double-Click
A handler method is a class method (static method) or an instance method of an object. If a class method is defined as a handler method, no object of the handled class needs to be instantiated to use the method.
To create a handler object for an event, define a class. This class has a public method in the public section that can react to an event. During the implementation of the handler method, define the source text that must be run when the event is triggered. The method receives the information that the event delivers from the mouse position when you double-click, and creates an information message in the control example that displays the row and field of the mouse click.