ABAP List Viewer is used to enhance the readability and functionality of any report output. We can develop ALV using different ways like using type pool SLIS or using the class Cl_GUI_ALV_GRID. In case of Object-Oriented concept, the Control Framework is required as it provides global classes for various functionalities.
It is the wrapper class implemented to encapsulate ALV Grid functionality for list display. ALV Grid control is a flexible tool which provides following capabilities:
- For building and displaying interactive, non-hierarchical and modern-design lists.
- Provides typical list functions such as sorting, filtering, summing etc.
- Provides common list operations and can be enhanced by user-defined options.
Basic Components required for ALV Grid Control are:
- List Data : Data to be listed is populated in an internal table. This table can be of any flat type
- Field Catalog: This is an internal table which contains the list of fields as per specification. It comprises of some additional information about display options for each column to be displayed. It must be referenced to the dictionary type “LVC_T_FCAT” while the work-area should be of type “LVC_S_FCAT”. Function “LVC_FIELDCATALOG_MERGE” can also be used to get field catalog by passing structure name.
- Container: Container is a storage area where the list will be displayed. It should be of type “CL_GUI_CUSTOM_CONTAINER”. Other Container Classes are:
- CL_GUI_DOCKING_CONTAINER- For displaying multiple ALV’s by using methods such as dock_at_left, dock_at_right, dock_at_top, dock_at_bottom. Internal tables can be displayed in these containers.
- CL_GUI_EASY_SPLITTER_CONTAINER- For displaying two ALV Grids on single screen, container is splitted into two containers by using this class.
- CL_GUI_DIALOGBOX_CONTAINER- This is used in case of Interactive ALV, where details list will be displayed in dialog box. For this functionality refer to example BCALV_GRID_02.
- Layout Structure: It is a structure to specify general layout options for the grid. With this structure we can set general display options, grid customizing, totals options, color adjustments etc. The layout structure must be of type “LVC_S_LAYO”.
- Event Handler: For handling events, we need to define and implement an event handler class triggered by the ALV Grid instance. After creating ALV Grid instance, we must register an instance of this event handler class to handle ALV Grid events.
Various Events are as follows-
- Print_Top_Of_Page: Used for Headers. Handler is ‘SET HANDLER’.
- Print_End_Of_Page: Used for Footers. Handler is ‘SET HANDLER’.
- OnDrag : This event is used to ‘fetch’ information from the drag source.
- OnDrop : This event is used to use the dragged information in combination with drop source. Here, it should be checked whether the operation is successful.
- OnDropComplete: This event is used to change the state after a successful drag and drop operation. For example: update the used internal table if a row has been moved.NOTE: For Drag and Drop functionality refer to these standard examples-BCALV_DND_01- Drag ALV row to Tree Folder
BCALV_DND_02- Drag Icons from Tree to rows of Grid
BCALV_DND_03- Drag & Drop on cells of grid
BCALV_DND_04- Drag & Drop within ALV Grid Control
BCALV_GRID_DND_TREE- ALV Grid: Drag and Drop with ALV Tree
BCALV_GRID_DND_TREE_SIMPLE- ALV Grid: Drag and Drop with ALV Tree (Simple)
- Additional Data: To trigger some additional features of ALV Grid we can have some additional data to pass as parameters. For example, initial sorting criteria (class used is LVC_S_SORT), buttons to be deactivated, GUI Status and title etc.
General Declarations and Steps to Create Object-oriented ALV:
Please send us your questions, comments or assistance, and our team would be glad to assist you.
By Sreedhar Babu (on behalf of SAP Consulting Team)
SAP :: Streamlined
We offer variety of services including SAP ECC ,SAP HR,SAP BW,SAP CRM, SAP SCM,SAP BPM, Business Objects, SAP ABAP Development, SAP BASIS and SAP NetWeaver consulting. We have expertise in providing implementation,development, SAP Migration and SAP support services to SAP customers across diverse industries at a global level.
Have a question on SAP? Write to our SAP Architect.
(We promise a no-obligation consulting reply)