The OO ALV is ALV using object-oriented ABAP. ALV stands for ABAP List Viewer and provides the standard list format and user interface for all the ABAP programs. The advantage of using OOPS ALV in SAP ABAP is that is flexible and used to build interactive and modern-designing list. SAP has provided a class (class name: CL_GUI_ALV_GRID) which acts as the wrapper class encapsulating ALV GRID functionality.
The basic components for ALV Grid are:
- List data: List data are the internal table data’s to be listed.
- Field Catalog: The field catalog is the internal table that defines the specification on the display of fields. To generate field catalog there are three methods: Automatic generation, semi-automatic generation and manual generation. The internal table must be referred to LVC_T_FCAT.
- Layout Structure: The layout structure must be of type “LVC_S_LAYO”. This can be used to modify the layout including colour adjustments, grid customization etc.
- Event Handler: To handle events triggered by ALV, event handler class should be defined and implemented.
- Additional Data: To stimulate additional data in ALV Grid, additional data should be passed as a parameter.
Follow the steps to create an OOPS ALV in SAP ABAP:
- Create an object of class CL_GUI_CUSTOM_CONTAINER and class CL_GUI_ALV_GRID.
- Populate internal table.
- Call screen in which you want to display the list.
- Create Custom Container from layout lab
- Call method of class CL_GUI_ALV_GRID and pass the required parameters.
“SCARR is the SAP Standard table which stores Airlines data
DATA: t_flight TYPE TABLE OF SCARR.
DATA: cust_container TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
cust_grid TYPE REF TO CL_GUI_ALV_GRID.
Select * from SCARR into table t_flight.
CALL screen 100.
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS ‘SCREEN1’.
SET TITLEBAR ‘AIRLINES LIST’.
MODULE USER_COMMAND_0100 INPUT.
LEAVE TO SCREEN 0.
MODULE LIST OUTPUT.
CREATE OBJECT CUST_CONTAINER
CONATINER_NAME = ‘CONATINER’ .
CREATE OBJECT CUST_GRID
I_PARENT = CUST_CONTAINER.
CALL METHOD CUST_GRID -> SET_TABLE_FOR_FIRST_DISPLAY
i_structure_name = ‘SCARR’
it_outtab = t_flight.