You are on page 1of 5

ABAP List Viewers (ALV):

The name itself indicates that the output view of a report is in the form of a list. This
list can be displayed in two forms

1. ALV List Form


2. ALV Grid Form
This article covers only ALV grid form. This is the most preferable form because of its GUI
capability. When coming to the implementation part of ALV Grid using OOPs concept, we can
use the existing classes for generating ALV output: Here I am listing some of the widely used
classes and its purpose:

1. CL_GUI_ALV_GRID
2. CL_GUI_CUSTOM_CONTANIER
3. CL_GUI_SPLITTER_CONTAINER
4. CL_GUI_CONTAINER
5. CL_DD_DOCUMENT
6. CL_GUI_HTML_VIEWER
7. CL_ALV_CHANGED_DATA_PROTOCAL
8.
CL_GUI_ALV_GRID: This class contains all the methods required to create an ALV and
holds the events required for the generated ALV. The methods in this class are useful for:

1. Setting the field catalog and its layout


2. For assigning the ALV to the Custom container
3. For changing the field catalog contents
4. For adjusting the ALV display and the list goes like this.
I will explain how to use the methods and events with an example at the end of this
article.

CL_GUI_CUSTOM_CONTAINER: It holds the Custom control that is created on the screen


layout. The link to the custom control to the ALV will be done using this container class.
CL_GUI_SPLITTER_CONTANIER: Using this class we can split the container into several
parts based on the requirement.
For instance, there may be a requirement in which top portion of the ALV Grid must hold the
company logo and some other details like date and user ID and the remaining part must
hold the loaded data. In this case we can use this class to split the container into two parts
one for holding the company details and the other contains all the records.
CL_GUI_CONTAINER: This class is also useful while splitting a container. Each container
part that is separated using the above class holds the form of this class.
CL_DD_DOCUMENT: This class is used to write text or labels or variables or logos etc., on
the container layout.
CL_ALV_CHANGED_DATA_PROTOCAL: If the ALV is in edit mode then the changed values
can be viewed through this class.
The following example demonstrates how to make use of the methods and events of
CL_GUI_ALV_GRID.

SALV_DEMO_TREE_DATA_UPDATE Demonstration Program for ALV OM Tree: Changed Data


SALV_DEMO_TREE_EVENTS Demonstration Program for ALV OM Tree: Events
SALV_DEMO_TREE_FUNCTIONS Demonstration Program for ALV OM Tree: Functions
SALV_DEMO_TREE_METADATA Demonstration Program for ALV OM Tree: Metadata
SALV_DEMO_TREE_SELECTIONS Demonstration Program for ALV OM Tree: Selections
SALV_DEMO_TREE_SETTINGS Demonstration Program for ALV OM Tree: Settings
SALV_DEMO_TREE_SIMPLE Demonstration Program for ALV OM Tree

Getting and Modifying Subobjects of a Main Class


Purpose
The ALV object model includes a large number of classes that you can use to make specific settings. The
following graphic compares the class diagram of the three main ALV classes.
Naming Conventions
The classes of the ALV object model are structured that you can usually tell from the names which areas
of the ALV output you can change with the methods from these classes.
• Singular or plural
Often you will find class names that exist in both plural and in singular (such as
CL_SALV_COLUMN and CL_SALV_COLUMNS). You can see from the names that in the one
class there are methods that only affect a specific object and in the other class the methods are for
all of these objects.
• ALV tool
Many functions are available for all three ALV tools. However, when there are differences between
the classes of the ALV tools, you can find the right variant by the name (such as
CL_SALV_COLUMN_TABLE, _SALV_COLUMN_HIERSEQ, CL_SALV_COLUMN_TREE)
Get Subobjects
You get the objects for these classes using the Get methods of the three main ALV classes. The following
table shows which methods in the main ALV classes provide which subobjects:
Methods of Main ALV Classes to Get Subobjects

Method Returns Object of Type Remarks


GET_AGGREGATIONS CL_SALV_AGGREGATIONS
GET_COLUMNS CL_SALV_COLUMNS_TABLE or
CL_SALV_COLUMNS_HIERSEQ or
CL_SALV_COLUMNS_TREE
GET_DISPLAY_SETTINGS CL_SALV_DISPLAY_SETTINGS Not in CL_SALV_TREE
GET_EVENT CL_SALV_EVENTS_TABLE or
CL_SALV_EVENTS_HIERSEQ or
CL_SALV_EVENTS_TREE
GET_FILTERS CL_SALV_FILTERS Not in CL_SALV_TREE
GET_FUNCTIONAL_SETTINGS CL_SALV_FUNCTIONAL_SETTINGS Not in CL_SALV_TREE
GET_FUNCTIONS CL_SALV_FUNCTIONS_LIST Not in CL_SALV_TREE
CL_SALV_FUNCTIONS_TREE Only in CL_SALV_TREE
GET_LAYOUT CL_SALV_LAYOUT
GET_LEVEL CL_SALV_HIERSEQ_LEVEL Only in
CL_SALV_HIERSEQ_TABLE
GET_NODES CL_SALV_NODES Only in CL_SALV_TREE
GET_PRINT CL_SALV_PRINT
GET_SELECTIONS CL_SALV_SELECTIONS Not in CL_SALV_TREE
CL_SALV_SELECTIONS_TREE Only in CL_SALV_TREE
GET_SORTS CL_SALV_SORTS Not in CL_SALV_TREE
GET_TREE_SETTINGS CL_SALV_TREE_SETTINGS Only in CL_SALV_TREE
If one of the classes uses another class, you can also get its objects using the Get methods.
Class Used Includes Get method Returns Object of Type
CL_SALV_AGGREGATIONS GET_AGGREGATION CL_SALV_AGGREGATION
CL_SALV_COLUMNS_TABLE GET_COLUMN CL_SALV_COLUMN
CL_SALV_COLUMNS_HIERSEQ
CL_SALV_COLUMNS_TREE
CL_SALV _FUNCTIONAL_SETTINGS GET_DROPDOWNS CL_SALV_DROPDOWNS
GET_HYPERLINKS CL_SALV_HYPERLINKS
GET_TOOLTIPS CL_SALV_TOOLTIPS
CL_SALV_FUNCTIONS_LIST GET_FUNCTIONS CL_SALV_FUNCTION
CL_SALV_FUNCTIONS_TREE
CL_SALV_FILTERS GET_FILTER CL_SALV_FILTER
CL_SALV_NODES GET_NODE CL_SALV_NODE
CL_SALV_SORTS GET_SORTS CL_SALV_SORT

Process Flow
If you have created the internal data table and the instance of the ALV main class, you are able to
generate an object for each class used and make the settings as well. To do this, proceed as follows:
• You declare an object variable for each type of class that you want to use
(such as data: gr_display type ref to cl_salv_display_settings. )
• You use the respective Get method the main ALV class to get the objects of the corresponding
type
(for example gr_display = gr_table->get_display_settings ( ). )
• You use the methods of the class used to assign the desired properties to the object.
(For example
gr_display->set_striped_pattern(
value = 'X').
gr_display->set_vertical_lines(
value = 'X').)
When you have made the settings you display the ALV output with the display method.

You might also like