ClassBook-Lessons-ABAP Part II Lesson2 - ALV
ClassBook-Lessons-ABAP Part II Lesson2 - ALV
There are some function modules which will enable to produce the above
reports without much effort.
All the definitions of internal tables, structures and constants are declared
in a type-pool called SLIS.
The important function modules are:
▪ Reuse_alv_fieldcatalog_merge
▪ Reuse_alv_list_display
▪ Reuse_alv_grid_display
Reuse_ALV_fieldcatalog_merge:
▪ This function module is used to populate a fieldcatalog which is essential to display
the data in ALV.
▪ If the output data is from a single dictionary table and all the columns are
selected, then we need not exclusively create the field catalog.
▪ Its enough to mention the table name as a parameter(I_structure_name) in the
REUSE_ALV_LIST_DISPLAY.
▪ In other cases, it has to be created.
RESUSE_ALV_LIST_DISPLAY REUSE_ALV_GRID_DISPLAY
CL_GUI_ALV_GRID
▪ The wrapper class implemented to encapsulate ALV Grid functionality for list
display.
While preparing a list to be displayed via an ALV grid control, we have some
basic components to prepare. These are:
List data :
▪ Data in an internal table to be listed
Field Catalog :
▪ Define specifications on how the fields of our list will be displayed
▪ Has technical and additional information about display options for each column to
be displayed.
▪ The internal table for the field catalog must be referenced to the dictionary type
LVC_T_FCAT.
Container
▪ Storage area where the list will be displayed.
▪ It should be of type CL_GUI_CUSTOM_CONTAINER
Layout Structure :
▪ Fill a structure to specify general layout options for the grid
▪ To set
• general display options
• grid customizing
• totals options
• color adjustments etc...
▪ The layout structure must be of type LVC_S_LAYO.
Event Handler
▪ To handle events triggered by the ALV Grid instance.
▪ Upon creating ALV Grid instance, 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’.
• OnDropComplete
‒ Event to change the state after a successful drag and drop operation.
• OnDrag
‒ To ‘fetch’ information from the drag source.
• OnDrop
‒ Used to use the dragged information in combination with drop source. Here, it should be checked
whether the operation is successful
Call the screen that contains the CUSTOM CONTAINER, in which the list has
to be displayed.
The work in this procedure is just filling the internal table for the field
catalog. We have already seen the structure of a field catalog. To achieve
filling the field catalog correctly, one must at least fill the above fields of the
field catalog structure for each column of the list.
LS_FCAT-INTTYPE = 'C'.
LS_FCAT-OUTPUTLEN = '3'.
CLEAR LS_FCAT.
LS_FCAT-FIELDNAME = 'CONNID'.
LS_FCAT-REF_TABLE = 'SFLIGHT'.
LS_FCAT-REF_TABLE = 'CONNID'.
LS_FCAT-OUTPUTLEN = '3'.
It comes now painting our ALV Grid in a general aspect. To define general
appearance of our ALV Grid we fill a structure of type “LVC_S_LAYO”. This
table contains fields and functionalities serviced by this adjustment. Some
of the generally used options are as below:
Data transfer to the ALV control takes place during the call of method
“SET_TABLE_FOR_FIRST_DISPLAY” of class “CL_GUI_ALV_GRID”. The
method call must be programmed at the PBO event of the screen with the
SAP Grid Control container.
Remember to use Pattern > ABAP Objects > Method of a Class
It is possible to set sort conditions for the table data. This is achieved by
filling an internal table of structure “LVC_T_SORT” which consists of the sort
criteria. To have an initial sorting, pass it to the parameter “IT_SORT” of the
method “SET_TABLE_FOR_FIRST_DISPLAY”.
The procedure is like the one in sorting. Here, the type of the table you
must fill is “LVC_T_FILT”.
Filling this table is similar to filling a RANGES variable.
Additional Event based Functionalities that the ALV Grid can handle:-
▪ GENERAL SCHEME FOR THE EVENT HANDLER CLASS
▪ HOTSPOT CLICKING
▪ DOUBLE CLICKING
▪ PUSHBUTTONS ON THE LIST
▪ ADDING YOUR OWN FUNCTIONS
▪ OVERRIDING STANDARD FUNCTIONS
▪ MAKING ALV GRID EDITABLE
▪ CONTROLLING DATA CHANGES
▪ LINKING F1 HELP TO FIELDS
▪ LINKING F4 HELP TO FIELDS