ALV Object Model 1
description
Transcript of ALV Object Model 1
-
ALV Object Model
Main ALV Classes
An Overview of ALV Tools
Display Types
ALV Output Display
Getting and Modifying Subobjects of a Main Class
Content of the ALV Output
Set Internal Data Table
Content and Structure Change
Areas of the ALV Output
Title of the ALV Output
Columns (General)
Change of DDIC Reference for a Column
Column Header
Lead Columns
Columns with Special Technical Meaning
Header and Footer Areas of the ALV Output
Design Object Compilation
Displaying a Design Object for the Complete ALV Output
Display Page Header and Footer
Special Functions of the Hierarchical-Sequential List
Special Functions of the Tree Structure
Basic ALV Functions
Sorting by Columns
Filter Data Rows
Making Calculations (Aggregation)
Make Settings for Aggregation
Results Rows
-
Generating Intermediate Results
Settings Management in Layouts
Selecting Cells, Rows and Columns
Determining the Appearance of the ALV Output
Color Definition for Columns, Rows and Cells
Setting Text Properties
Hiding Lines Between Columns and Rows
Changing the Display of Numeric Values
Define Column Width
Arranging a Data Record in Multiple Rows
ALV Output Display in a Dialog Box
Handling Events and Functions
Make Functions Available
Use of Generic ALV Functions
Using Self-Defined, Application-Specific Functions
Interactive Element Display
Checkbox Display
Display the Pushbutton
Internet Address Display
Click Area Display
Handling Single and Double Clicks
Handling Keyboard Actions
Providing Help for Users
Provide Tooltips
Tooltip Object Generation and Management
Generation of ToolTips for Icons and Symbols
F1 Help Provision
Making Settings for Printing
-
ALV Object Model
The new object model of the SAP List Viewer (ALV) is an object-oriented encapsulation of the ALV tool that
already exists.
Simple, two-dimensional table
Hierarchical-sequential list
Tree structure
The following objectives were fulfilled with the new ALV interface:
Unified, object-oriented API for all ALV tools wherever possible
Coherent API
Earliest possible error detection during programming (for example, exceptions let you know when methods
are not possible in specific situations)
Functions for accessibility are integrated into ALV, which means that you do not have to provide these
functions yourself using your application
With the ALV object model, you have the option of using almost unified programming techniques independent of
the ALV tool in order to display various lists, tables or tree structures. The methods, parameters or classes only
vary where tool-specific functions require a special procedure.
This documentation is catered toward application developers who want to display table-type structures as tables,
lists or tree structures in their applications using one of the ALV tools. Here you will find an overview of the mode
of operation of ALV, as well as the options you have for changing the appearance and functioning of the ALV
output from within your application.
You will find more detailed information about the classes and methods, including their parameters, in
the system documentation for classes and methods. You will find all classes of the new object model
in the SALV package and its subpackages.
Main ALV Classes
Use
You are using the ALV object model with one of the following main ALV classes:
CL_SALV_TABLE for the simple, two-dimensional table
CL_SALV_HIERSEQ_TABLE for the hierarchical-sequential list
CL_SALV_TREE for the tree structure
If you have decided on one of the ALV tools, you use the corresponding main ALV class to make all the
settings that you need for the ALV output.
-
Structure
In the ALV main classes, you will find somewhat uniform methods that you use to provide the required
specifications:
Minimum Information
In each of the three main ALV classes, you must call at least the following methods to obtain your
desired ALV output:
You instantiate the main ALV class:
You define the internal data table that provides the structure and content of the ALV output,
as needed.
You define which display type you want to use for the ALV output.
You display the ALV output on your screen.
Optional Methods in All Main ALV Classes
You can also make a variety of settings to control the ALV output.
The following list includes some examples for methods that you are able to use in all three main ALV
classes:
GET_COLUMNS
You get a reference to the individual column objects of the ALV output and make all the
technical settings for a column.
GET_FUNCTIONS
You get a reference to the function object of the ALV output and use it to define which
functions the user is able to use when working with ALV.
GET_EVENT
You get a reference to the events that you are able to process in the ALV output.
Depending on the main ALV class in which you are using these methods, they return objects of
different types.
Optional, Class-Specific Methods
The three main ALV class are based on various data models. This means you can also make various
settings, depending on which ALV tool you are using.
The following list includes some examples for methods that you are able to use only in specific main ALV
classes:
GET_LEVEL
This method can only be found in the main ALV class CL_SALV_HIERSEQ_TABLE. There
you get a reference to the objects in the two hierarchy levels.
GET_NODES
-
This method can only be found in the main ALV class CL_SALV_TREE. There you get a
reference to the node objects (rows) of the tree structure.
GET_SORTS
You are only able to sort in the simple, two-dimensional table or in the hierarchical-
sequential list. This method is not available in the tree structure.
The Getting and Modifying Subobjects for a Main Class chapter includes the class diagrams for the three
main ALV classes, along with information on the getter methods that you use to retrieve the
respective objects.
An Overview of ALV Tools
With the ALV tools, you are able to display the table-type structures in different ways.
Simple, two-dimensional table
They contain any number of rows, that
each have the same structure
have no hierarchical relationships to one another
The structure is defined by the columns. Every column has specific properties that are automatically
transferred to the values of the column.
Hierarchical-Sequential List
Hierarchical-sequential lists consist of any number of rows that are divided into exactly two hierarchy
levels. This differentiates between header and position rows: position rows are subordinate to the
header rows. For every header, there can be any number subordinate position rows.
-
Tree structure
In tree structures you display the table-type data in any number of hierarchy levels. The rows of the
tree structure are called nodes. Every node, no matter which hierarchy level it is on, has the same data
structure. However, the nodes are related to one another hierarchically, such as superordinate or
subordinate nodes (parent-child relationship) or nodes on the same level (sibling-sibling relationship).
Display Types
Definition
For the ALV output, independent of the ALV tool, you are able to choose between up to three display
types:
Classic ABAP list
The ALV output takes up the whole screen. This means you are only able to display one ALV output. The
screen is part of ALV.
Full screen display
The ALV output takes up the whole screen. This means you are only able to display one ALV output. The
screen is part of ALV.
In a SAP GUI container
You create a container with class CL_GUI_CONTAINER in your screen. The ALV output is displayed in this
container. With this type of display, you are able, for example, to display more than ALV output on the
screen or to mix the output with other SAP Enjoy controls.
You are also able to display the simple, two-dimensional table and the hierarchical-sequential list in a
separate dialog box, the ALV popup.
Use
The table that follows shows which display types you are able to use in which ALV tool:
ALV Tools and Their Possible Display Types
Display type
ALV Tool
Classic
ABAP list
Full screen In the
Container
Simple, two-dimensional table Yes Yes Yes
Hierarchical-sequential list Yes No No
-
Tree structure No Yes Yes
Some functions that you are able to apply with the ALV object model are not available in all display
types. In the following chapters of this document, you will learn which functions you can use where
and where you cannot use them. In places where the functions differ, you will find the following table:
Display type
ALV Tool
Classic
ABAP list
Full
screen
In the
Container
Simple, two-dimensional table Yes Yes Yes
Hierarchical-sequential list
No
Tree structure Yes Ja
The gray fields here display that this display type is not available in the
corresponding ALV tool.
The display types designated with Yes are the ones in which you can use the
described function. At the end of each table you will find information on how you can
activate the function.
The display types designated with No are the ones in which the function is not
possible.
Difference Between Display Types
Display types have different properties that affect the way the can be used. The following list shows the
most important differences between the display types:
Managing the Screen
You are able to use the ALV object model to control the entire screen in the following display types:
In the classic ABAP list
In the full-screen display
With ALV object model methods, you the have the option of defining the screen status and the header or footer
area of the ALV output.
On the other hand, if you use the display in a GUI container, the effect of the methods on the area within
the container is limited. The screen status and header/footer area of the ALV output cannot be reached
from the ALV object model.
Appearance
Above all, the classic ABAP list looks different from the other two display types:
The classic ABAP list looks like a traditional, row-oriented output. You only have limited options for
formatting and using color. Especially in the areas above and below the list, you are only able to use one
font and very few text colors.
The full screen and the output in the container look very similar. Some elements appear three dimensional
(for example, the column header as a pushbutton); the font and colors are more varied. You are also able
to use lines and other graphic elements.
-
However, you are only able to change the areas above and below the ALV output using the ALV object
mode only in display types in which ALV has control over the whole screen. There, various design
options are available to you:
Application Toolbar
The only area outside of the actual ALV output that you can also influence in the container as well is the
application toolbar. In the Classic ABAP List and Full Screen display types; if you are using functions,
this is located directly below the screen title. In the container display it is on the upper edge of the
container.
In the container displays, you change the application toolbar with the object model methods directly. In
the other display types, you design the application toolbar using the screen status.
Methods
The majority of methods in the ALV object model are valid no matter which display type you use for the
ALV output. Nevertheless, there are a number of differences, especially in the graphical design options,
which means that some methods are not possible in specific display types. Read the system
documentation for the classes and methods.
Set Up Display Type
You use the FACTORY method to determine which display type you want to use for your ALV tool. This
method is available to you in all three main ALV classes. However, since you are not able to vary the
display type in the hierarchical-sequential list, the following sections only refer to simple, two-
dimensional tables and the tree structure.
Setting Up Display Type in a Simple, Two-Dimensional Table
In the CL_SALV_TABLE class, the FACTORY method gets the following parameters that are relevant for
the display type:
LIST_DISPLAY
R_CONTAINER
CONTAINER_NAME
You determine how the table is displayed with a combination of these parameters.
Parameter Settings for the Display Type
Parameter
Display type
LIST_DISPLAY R_CONTAINER CONTAINER_NAME
Classic ABAP list ABAP_TRUE Initial Initial
Full screen ABAP_FALSE Initial Initial
In the Container ABAP_FALSE Reference to container; type
CL_GUI_CONTAINER
Name of the container
Setting Up Display Type in the Tree Structure
In the tree structure, you are able to choose whether you wish to display the ALV output as full screen
or in a container. To do this, use the R_CONTAINER parameter from the FACTORY method:
If you transfer a container (Type
CL_GUI_CONTAINER), you display the tree structure in this container.
-
If the parameter is initial, you display the tree structure as full screen.
ALV Output Display
Use
To display the ALV output on the screen, it is sufficient to use two methods of the ALV object model:
FACTORY
You instantiate the main ALV class:
You define the internal data table that provides the structure and content of the ALV output,
as needed.
You define which display type you want to use for the ALV output.
DISPLAY
To display the ALV output on the screen, call up the method DISPLAY afterwards.
Examples
Example of a Simple, Two-Dimensional Table
The following example shows the simplest call of a table of type SFLIGHT. The gt_outtab table is the
table with your application data and the gr_table is the reference to the ALV main class to be used.
data: gt_outtab type table of SFLIGHT.
data: gr_table type ref to cl_salv_table.
*... Select Data
select * from SFLIGHT into corresponding fields of table gt_outtab.
*... Create Instance
call method cl_salv_table=>factory
IMPORTING
R_SALV_TABLE = gr_table
changing
t_table = gt_outtab.
*... Display Table
gr_table->display( ).
Example of a Hierarchical-Sequential List
The following example shows the simples call of a hierarchical-sequential list.
The header level comes from the SCARR table, the position level from the SFLIGHT table. Its columns are
transferred into the table with your application data: gt_parent or gt_child.
Both tables contain the column CARRID that is used to form the foreign key relationship.
gr_table is the reference to the ALV output class to be used.
data: gt_parent type table of SCARR.
data: gt_child type table of SFLIGHT.
-
data: gr_table type ref to cl_salv_hierseq_table.
data: lt_binding type salv_t_hierseq_binding.
data: ls_binding type salv_s_hierseq_binding.
*... Select Data
select * from SCARR into corresponding fields of table gt_parent.
select * from SFLIGHT into corresponding fields of table gt_child.
*... Bind Parent and Child Table
ls_binding-master = 'CARRID'.
ls_binding-slave = 'CARRID'.
append ls_binding to lt_binding.
*... Create Instance
call method cl_salv_hierseq_table=>factory
exporting
t_binding_level1_level2 = lt_binding
importing
r_hierseq = gr_table
changing
t_table_level1 = gt_parent
t_table_level2 = gt_child.
*... Display Table
gr_table->display( ).
Example of a Tree Structure
The following example shows the simplest call of a tree structure of type SFLIGHT. The
gt_outtab2table is an empty table that only provides the structure of the tree. The table gt_outtab1is
the table that includes the desired data records..
gr_treeis the reference to the ALV output class to be used.
data: gt_outtab1 type table of sflight,
gt_outtab2 type table of sflight.
data: ls_outtab type sflight.
data: gr_tree type ref to cl_salv_tree.
data: nodes type ref to cl_salv_nodes,
node type ref to cl_salv_node.
*... Select Data
select * from sflight into corresponding fields of table gt_outtab1 up to 5 rows.
*... Create Instance with an Empty Table
-
call method cl_salv_tree=>factory
IMPORTING
R_SALV_TREE = gr_tree
changing
t_table = gt_outtab2.
*... Add the Nodes to the Tree
nodes = gr_tree->get_nodes( ).
loop at gt_outtab1 into ls_outtab.
try.
node = nodes->add_node( related_node = key
relationship = cl_gui_column_tree=>relat_first_child ).
node->set_data_row( ls_outtab ).
catch cx_salv_msg.
endtry.
endloop.
*... Display Table
gr_tree->display( ).
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
Set Internal Data Table
Use
With the ALV tool, you display table-type structures. For this reason, your application's first task is to
transfer a suitable data table to ALV. It does not matter whether you transfer an existing database table
(thus providing all DDIC information) or whether you define the fields of the data table yourself.
Based on various data models that are the basis for the ALV tools, you transfer different table tables to
ALV depending on which ALV tool you are using:
Simple, two-dimensional table
The data table has a relational structure.
-
Hierarchical-sequential list
The hierarchy of the list is restricted to two levels. For each of these levels, you transfer an internal data
table and link them with up to five foreign key relationships
Tree structure
The table that you transfer to the ALV object model only contains the structure. There is no data in this
table. To fill the tree structure, add the required nodes in the form of NODE objects one at a time.
Features
You are able to make the following settings for data table:
First determine data table
Determine display of empty data table
Setting the Data Table for the First Time with FACTORY
To set the internal data table for the first time, always proceed in the same way no matter which ALV
tool you are using: use the FACTORY method.
You can only use the FACTORY method the first time you call a table. To make changes to the table,
read the chapter Changing and Updating the Contents of the ALV Output.
Display type
ALV Tool
Classic ABAP
list
Full screen In the
Container
Simple, two-
dimensional table
Yes Yes Yes
Hierarchical-
sequential list
Yes
Tree structure Yes Yes
Depending on which ALV tool you are using, the parameters of the FACTORY method are different:
Setting the Data Table with the FACTORY method
ALV Tool Parameter Remarks
Simple, two-
dimensional table
T_TABLE Table for structure and contents of the ALV
output
Hierarchical-
sequential list
T_TABLE_LEVEL1 Table for header level
T_TABLE_LEVEL2 Table for position level
T_BINDING_LEVEL1_LEVEL2 List of up to five foreign-key relationships
Tree structure T_TABLE Initial table
Empty table, only sets the structure
Determine Display of Empty Data Table
By default, the following elements are displayed when the data table is empty.
-
The information from the design object for the header area of the list (if available)
The column header of the ALV output
A note that there is no data
You are able to determine that only the information from the design object for the header area of the list
be displayed.
Display type
ALV Tool
Classic ABAP
list
Full screen In the
Container
Simple, two-
dimensional table
Yes No No
Hierarchical-
sequential list
Yes
Tree structure No No
Methods
Function Class Method
Determine Display of
Empty Data Table
CL_SALV_
DISPLAY_SETTINGS
SET_SUPPRESS_EMPTY_DATA
Get display of empty
data table
GET_SUPPRESS_EMPTY_DATA
Content and Structure Change
Use
You are able to change the internal data table in various ways. Depending on which type of change you
use, you have to proceed differently to make the change visible on the front end in the ALV output as
well.
You are able to make the following changes:
You change content or the sequence of the individual data records
Afterwards you need to refresh the ALV output
You replace the entire data table
Refresh Display of the ALV Output
If you have changed single values, added rows or deleted rows in the data table of list-type ALV
outputs, you need to complete these changes in the ALV output as well by refreshing the ALV display.
-
For Changes in the Tree Structure you do not have to refresh the display. In the other ALV tools, you do
not have to refresh the ALV output when you make the following changes:
Changes to the Display of Columns
Changes Sequence of Columns in the ALV display
Changes to the DDIC Reference of Columns
By default, the ALV output automatically scrolls to the beginning. However, you are able to determine
that the current display (position on the screen) not be changed.
You are able to refresh the ALV output in two ways:
All settings for filters and sorting remain.
This setting can lead to newly inserted data records not being displayed because the filter setting hid
exactly these data records.
All settings for filters and sorting remain.
Features
For changes to content and structure, you are able to make the following settings:
Refresh ALV output
Swap the data table of the ALV output
Refresh ALV output
With the refresh, you ensure that the changed values are available on the front end as well.
Display type
ALV Tool
Classic
ABAP list
Full screen In the
Container
Simple, two-dimensional table Yes Yes Yes
Hierarchical-sequential list Yes
Tree structure No No
Methods
Function Class Method
Refresh ALV output
without deleting filter and
sort settings
CL_SALV_TABLE
CL_SALV_HIERSEQ_TABLE
REFRESH
(Parameter REFRESH_MODE:
SOFT)
Refresh ALV output and
delete filter and sort
settings
REFRESH
(Parameter REFRESH_MODE:
FULL)
Change the Structure of the Data Table with SET_DATA
Depending on which ALV tool you are using, the parameters of the SET_DATA method are different:
-
If you assign a new structure with SET_DATA, all objects that referred to the previous structure will
be deleted such as all sort objects in list-type ALV outputs or all node objects in tree structures.
Methods
Function Class Method
Change structure and data table CL_SALV_TABLE
CL_SALV_HIERSEQ_TABLE
CL_SALV_TREE
CL_SALV_HIERSEQ_LEVEL
SET_DATA
Change the Structure of the Data Table with the SET_DATA Method
ALV Tool Parameter Remarks
Simple, two-dimensional table T_TABLE Table for structure and contents of the ALV
output
Hierarchical-sequential list
(in
CL_SALV_HIERSEQ_TABLE)
LEVEL Hierarchy level whose structure you wish to
change
T_TABLE New table of hierarchy level
T_BINDING List of up to five foreign-key relationships
(in
CL_SALV_HIERSEQ_LEVEL)
VALUE New table of hierarchy level
T_BINDING List of up to five foreign-key relationships
Tree structure T_TABLE Initial table
Empty table, only sets the structure
Areas of the ALV Output
The ALV tools can be divided into several areas. Some of these areas are in every ALV tool, but others
are specially tailored to one ALV tool or to a specific display type of an ALV tool.
The following graphic shows the areas that you find in the display types in which ALV checks the whole
screen:
Simple, two-dimensional table:
classic ABAP list and full screen
Hierarchical-sequential list
-
Tree structure:
Full screen
In the display types in the container, there are fewer areas available to you:
Additionally, especially the hierarchical-sequential lists and the tree structure have areas that do not
exist in the other tools.
This chapter deals with the functions that you use to edit the various areas of the ALV output:
Title of the ALV Output
Columns
Results Rows for Calculations
Header and Footer Areas of the ALV Output
Areas in the Hierarchical-Sequential List
Areas in the Tree Structure
Title of the ALV Output
Use
The position of the title of the ALV output depends on which ALV tool you are using and also on the
display type:
Simple, two-dimensional table
With the classic ABAP List and Full Screen display types, the title is located in the
-
screen status. The title applies to the whole screen
In the full screen, you are also able to display the title above the ALV output.
With display in a container, the title is located on the upper edge of the container below
the application toolbar. The title is valid only for the area of the container
Hierarchical-sequential list
The title can be found in the screen status. The title applies to the whole screen
Tree structure
In the Full Screen display type, the title is located in the screen status. The title applies
to the whole screen
With the display in the container, you cannot use a title.
Features
You can make the following settings for the title of the ALV output:
Change wording of the title
Change font size of the title (only container display)
Output Standard Title of the Report
Change Wording of the Title
You are able to change the wording of the title in all three ALV tools.
Display type
ALV Tool
Classic
ABAP list
Full screen In the
Container
Simple, two-dimensional table Yes Yes Yes
Hierarchical-sequential list Yes
Tree structure Yes No
Methods
Function Class Method
Change wording of the title (simple,
two-dimensional table and
hierarchical-sequential list)
CL_SALV_DISPLAY_SETTINGS SET_LIST_HEADER
Get current title GET_LIST_HEADER
Change wording of the title (tree
structure)
CL_SALV_TREE_SETTINGS SET_HEADER
Get current title GET_HEADER
Change Font Size of the Title
In the container display of the simple, two-dimensional table, you are able to change the font size of the
title. In the full-screen display, you can only do this when you display the title in the ALV output.
Display type
ALV Tool
Classic
ABAP list
Full screen In the
Container
-
Simple, two-dimensional table No Only above the
ALV output
Yes
Hierarchical-sequential list No
Tree structure No No
Methods
Function Class Method
Change Font Size of
the Title
CL_SALV_DISPLAY_SETTINGS SET_LIST_HEADER_SIZE
Get current font size GET_LIST_HEADER_SIZE
Columns (General)
Definition
Columns are the main element of an ALV output. You can define a number of properties for a column to
change whether and how a value is displayed in the column.
Column Description
In the ALV object model, a COLUMN object (class CL_SALV_COLUMN) is generated automatically for
every column in your internal data table. All of the COLUMN objects are represented by the COLUMN
object (class CL_SALV_COLUMNS and its subclasses).
During generation of table instances, the ALV object model determines all relevant and available
properties from the DDIC description of your internal data table and assigns them to the individual
column objects.
If table columns refer to local program fields, ALV is only able to determine a part of the possible
column properties. These are mainly the technical descriptions such as internal length, internal type
and so on.
With the methods for class CL_SALV_COLUMN (or its subclasses), you define more properties as
needed. The following graphic shows the inheritance hierarchy of a column object:
Column Types
You are able to differentiate between the following column types:
Standard columns
-
Lead columns, which are columns that have a special textual meaning in your ALV output.
Special columns that control the meaning or display of other columns or that are reserved for special
functions
Some of the settings that you make for a column are valid for all of these column types, but some are
only reserved for a specific type of column.
Use
You are able to make the following settings for all columns.
Set the visibility of the column
Change Position of the Column within the ALV Output
Change Column Header
Columns with Special Meaning
Lead Columns
Setting the Properties of Text in the Column
Determining Appearance
Determining Width of a Column
Get Column Objects
The GET_COLUMNS method exists in each ALV main class. It returns the column descriptions of all
columns in the ALV output (all column objects). You use this object (class CL_SALV_COLUMNS) and the
GET method or GET_COLUMN methods to get the desired column description.
Methods
Function Class Method
Get all column objects CL_SALV_TABLE
CL_SALV_HIERSEQ_TABLE
CL_SALV_TREE
GET_COLUMNS
CL_SALV_COLUMNS GET
Get all column objects for
a hierarchy level
CL_SALV_HIERSEQ_LEVEL GET_COLUMNS
Get specific column object CL_SALV_COLUMNS GET_COLUMN
Get technical name of the
current column
CL_SALV_COLUMN
CL_SALV_ITEM
CL_SALV_AGGREGATION
CL_SALV_SORT
GET_COLUMNNAME
Set the Visibility of the Column
The column set of users are made up of columns that they can hide and display as needed. You have
various options for influencing a users column set:
You determine which columns users are shown when the ALV output appears on the screen. This setting
is a standard setting.
-
You determine which columns are contained in the column set, but are not being displayed on the screen:
You set the column as hidden.
For columns that you have defined as lead columns, you are able to determine whether the user can
hide them or not.
You are able to determine which columns should not be included in the user's column set: You define the
column as a technical column.
Most columns with special technical meaning are automatically technical columns and thus are not
included in the users column set.
Display type
ALV Tool
Classic
ABAP list
Full screen In the
Container
Simple, two-dimensional table Yes Yes Yes
Hierarchical-sequential list Yes
Tree structure Yes Yes
Methods
Function Class Method
Set the visibility of a column CL_SALV_COLUMN SET_VISIBLE
Check setting for visibility IS_VISIBLE
Define column as technical column SET_TECHNICAL
Check whether column is a technical
column
IS_TECHNICAL
Change Position of the Column within the ALV Output
You are able to change the sequence of the columns within the ALV output.
Display type
ALV Tool
Classic
ABAP list
Full screen In the
Container
Simple, two-dimensional table Yes Yes Yes
Hierarchical-sequential list Yes
Tree structure Yes Yes
The exception column is always displayed as the first column. You cannot change its position.
Methods
-
Function Class Method
Change the position of a
column
CL_SALV_COLUMNS SET_COLUMN_POSITION
Get current position of a
column
GET_COLUMN_POSITION
Change of DDIC Reference for a Column
Use
You are able to define columns as internal data tables yourself or you can use individual fields or whole
tables from the database. In the latter case, all information that is available for this element in the Data
Dictionary (DDIC) is transferred to the new column objects. In the former case, only those are
transferred that you provide with the definition.
For columns with DDIC reference, you are able to retrieve a variety of information on the properties of
the DDIC element.
You are also able to change description of column objects by creating or changing a DDIC reference.
Here you have the following options:
You change the description of an individual column
You change the description of multiple columns simultaneously.
No matter whether the type of your column agrees with that of the referenced DDIC field, the following
properties are always transferred to your column.
Short, medium and long text of the column header
F1 help text
If the typing also matches (internal type and internal length), the remaining properties are also
transferred, such as
F4 help and search help
Data element and domain
Columns for amounts, currency, decimal places and rounding
Features
You are able to make the following settings for DDIC references:
Get information on the DDIC element
Change DDIC reference of an individual column or of multiple columns
Use F1-Help from Another DDIC Element
The following is valid for all of these functions:
Display type
ALV Tool
Classic
ABAP list
Full screen In the
Container
Simple, two-dimensional table Yes Yes Yes
-
Hierarchical-sequential list Yes
Tree structure Yes Yes
Get information on the DDIC element
You are able to get all sorts of information that results from the DDIC reference of a column:
Methods
Function Class Method
Get name of the DDIC data
element
CL_SALV_COLUMN GET_DDIC_ROLLNAME
Get DDIC data type GET_DDIC_DATATYPE
Get DDIC decimal places GET_DDIC_DECIMALS
Get DDIC domains GET_DDIC_DOMAIN
Get output length according to
DDIC (CHAR)
GET_DDIC_OUTPUTLEN
If a column does not have a DDIC reference, you are able to retrieve the following properties:
Internal length
To do this, use the method GET_DDIC_INTLEN
Internal type
To do this, use the method GET_DDIC_INTTYPE
Change DDIC Reference of an Individual Column or of Multiple Columns
You are able to create or change the DDIC reference for one or more columns. If multiple columns of
your ALV output have the same name as the fields in a DDIC structure that already exists, you assign
the entire DDIC structure to your ALV output. Columns with the same name get the properties of the
corresponding fields of the DDIC structure.
Methods
Function Class Method
Change DDIC reference for an
individual column
CL_SALV_COLUMN SET_DDIC_REFERENCE
Get DDIC reference for the
column
GET_DDIC_REFERENCE
Change DDIC reference for
several columns
CL_SALV_COLUMNS APPLY_DDIC_STRUCTURE
-
Column Header
Definition
The column header displays the name of a column for the user. You are able to define three different
texts as column header.
Use
You are able to make the following settings for the column header:
Determine wording of the column header
Display or hide column header
Determine whether the user can sort the table according to this column by clicking on the column header
Determine tooltip for the column header
Display an icon (only tree structure)
Determine Wording of the Column Header
The column header is a property of the COLUMN object. In this way you are able to specify the column
header for every column in the internal data table.
You can specify three different variants of the column header: The long, medium and short column
header. If the user changes the column width, the column header that fits the column best is
automatically used.
A special case is the column header of the hierarchy column in the tree structure: Because there is
no COLUMN object for this column, you determine this column header using the properties of the
tree structure.
Display type
ALV Tool
Classic
ABAP list
Full screen In the
Container
Simple, two-dimensional table Yes Yes Yes
Hierarchical-sequential list Yes
Tree structure Yes Yes
Methods
Function Class Method
Determine version of the
column header
CL_SALV_COLUMN SET_LONG_TEXT
SET_MEDIUM_TEXT
SET_SHORT_TEXT
Get current column
header
GET_LONG_TEXT
GET_MEDIUM_TEXT
GET_SHORT_TEXT
-
Determine column header
of the hierarchy column of
a tree structure
CL_SALV_TREE_SETTINGS SET_HIERARCHY_HEADER
Get column header of the
hierarchy column of a tree
structure
GET_HIERARCHY_HEADER
Display or Hide Column Header
You are able to determine whether the column header is visible or not in the ALV output. You make this
setting for all column headers of the ALV output.
Display type
ALV Tool
Classic
ABAP list
Full screen In the
Container
Simple, two-dimensional table Yes Yes Yes
Hierarchical-sequential list Yes
Tree structure No No
Methods
Function Class Method
Display or hide column header CL_SALV_COLUMNS_LIST SET_HEADERS_VISIBLE
Check whether column headers
are being displayed or hidden
IS_HEADERS_VISIBLE
Sort by Clicking on Column Header
You are able to determine that the column header serve as a pushbutton for sorting the table. The sort
direction is then indicated as a small arrow pointing up or down.
Display type
ALV Tool
Classic
ABAP list
Full screen In the
Container
Simple, two-dimensional table No No Yes
Hierarchical-sequential list No
Tree structure No No
Methods
Function Class Method
Set column header as pushbutton
for sorting the table
CL_SALV_
FUNCTIONAL_SETTINGS
SET_SORT_ON_
HEADER_CLICK
Check whether column header is
set as pushbutton for sorting the
table
IS_SORT_ON_
HEADER_CLICK
-
Determine Tooltip for the Column Header
You are able to define a text that will be displayed when the user rests the mouse pointer on the column
header for a moment.
Display type
ALV Tool
Classic
ABAP list
Full screen In the
Container
Simple, two-dimensional table Yes Yes Yes
Hierarchical-sequential list Yes
Tree structure Yes Yes
The tooltip for the hierarchy column in the in the tree structure is a special case: Because there is no
COLUMN object for this column, you determine this tooltip using the properties of the tree structure.
Methods
Function Class Method
Determine tooltip for the column
header
CL_SALV_COLUMN SET_TOOLTIP
Get current tooltip for a column
header
GET_TOOLTIP
Set tooltip for hierarchy column
of a tree structure
CL_SALV_
TREE_SETTINGS
SET_HIERARCHY_TOOLTIP
Get tooltip for hierarchy column
of a tree structure
GET_HIERARCHY_TOOLTIP
Get all tooltip objects for column
headers of the tree structure
GET_TOOLTIPS
Display Icon
In the column header of the hierarchy column for a tree structure, you can display an icon.
Display type
ALV Tool
Classic
ABAP list
Full screen In the
Container
Simple, two-dimensional table No No No
Hierarchical-sequential list No
Tree structure Yes Yes
Methods
Function Class Method
-
Display icon in the column
header of the hierarchy
column ??
CL_SALV_
TREE_SETTINGS
SET_HIERARCHY_ICON
Get icon currently being
displayed
GET_HIERARCHY_ICON
Lead Columns
Definition
Lead columns are columns that have a special significance in the output. Usually you define columns
that contain especially important content as lead columns.
Columns that have already been designated by the application as primary key automatically become
lead columns in the ALV object model.
The following properties differentiate a lead column from a normal column:
Lead columns have a different color. This color is determined by the system.
You are able to determine whether a lead column moves when you scroll sideways through the screen like
the other columns, or whether it stays where it is.
Lead columns can be found in the users column set. By default, the user is able to hide lead columns.
You are able to prevent users from hiding lead columns.
For all of the following functions, this is valid:
Display type
ALV Tool
Classic ABAP list Full screen In the Container
Simple, two-dimensional table Yes Yes Yes
Hierarchical-sequential list Yes
Tree structure No No
Use
You are able to make the following settings for lead columns:
Define the column as a lead column
Determine the color of individual cells in the lead columns
Prevent lead columns from scrolling
Prevent lead columns from being hidden
Defining the Column as a Lead Column
You are able to define any column of the ALV output as a lead column.
Methods
-
Function Class Method
Define lead columns CL_SALV_COLUMN_LIST SET_KEY
Check whether a column is a lead column IS_KEY
Defining a Color in a Lead Column
Lead columns have their own background color that helps you to differentiate between them and the
regular columns in your ALV output. This color is determined by the system. You are not able to change
the color of the whole column. However, you are able to override the predefined background color for
individual cells of the lead column: You define a separate color column, where you specify one of the
possible alternative colors for the desired cell. You also use the NOKEYCOL field in the color column to
explicitly deactivate the system color.
Methods
Function Class Method
Define color column CL_SALV_COLUMNS_LIST SET_COLOR_COLUMN
Get color column GET_COLOR_COLUMN
Prevent Lead Columns from Scrolling
If there is not enough room for all of the columns of the ALV output to be displayed on the screen
simultaneously, the user can scroll sideways until the desired column becomes visible. Usually the
other columns disappear when you are doing this. You are able to determine whether the lead columns
are fixed, which means that they remain visible when you scroll sideways.
Methods
Function Class Method
Fix lead columns CL_SALV_COLUMNS_LIST SET_KEY_FIXATION
Checks whether the lead columns are fixed HAS_KEY_FIXATION
Preventing Lead Columns from Being Hidden
By default, users can hide or display columns that are part of their column set as needed. You are able
to prevent users from hiding each lead column individually.
Methods
Function Class Method
Prevent lead columns from
being hidden
CL_SALV_COLUMN_LIST SET_KEY_PRESENCE_REQUIRED
Check whether the lead
column can be hidden
IS_KEY_PRESENCE_REQUIRED
-
Columns with Special Technical Meaning
Definition
As a rule, columns from the internal data table are displayed directly in the ALV output. However, you
are able to define columns that have a special technical function. These columns are then either not
displayed at all or their content is presented in a special way. You are able to use the following types of
special columns:
Control columns
These columns are technical columns, which means they are usually not displayed. They contain
information on how the contents are being displayed in another column.
Examples of control columns are:
Color column (technical column)
Currency column (visible column)
Many of the properties that you assign to specific cells using control columns can also be assigned
to a whole column (for example assigning a currency to a whole column).
Graphic columns
To display icons, exceptions and symbols, you use specific notation (for example @AB@). So that these
character strings are interpreted as IDs for a graphic and not as text, you define the column accordingly as
an icon-, exception or symbol column.
Columns with special function
These columns include functions that are only useful in very specific situations.
Examples of these columns include:
Expansion column for the hierarchical-sequential list
Text Column for Labels in Results Rows for Intermediate Results
Counter Column to Determine the Number of Rows
Use
Depending on how you use a special column, you need to be aware of different things.
Using Control Columns
With control columns you assign specific properties to one or more cells.
An entry in the control column always refers to cells from those rows that include the entry as well.
There are two types of control columns:
Control columns that are fixed and assigned to a specific column.
Control Columns That Contain Information for Any Number of Columns
Control Columns That are Assigned to a Specific Column
Specifications in the control column exclusively refer to the current column. The cells of this control
column each can only contain one value that controls the content of the linked cell.
-
For this type of control columns, use the following methods:
Control column Class Method
Currency column CL_SALV_COLUMN SET_CURRENCY_COLUMN
GET_CURRENCY_COLUMN
Column for decimal places SET_DECIMALS_COLUMN
GET_DECIMALS_COLUMN
Column for units of measure SET_QUANTITY_COLUMN
GET_QUANTITY_COLUMN
Rounding column SET_ROUND_COLUMN
GET_ROUND_COLUMN
Display type
ALV Tool
Classic
ABAP list
Full screen In the
Container
Simple, two-dimensional table Yes Yes Yes
Hierarchical-sequential list Yes
Tree structure Yes Yes
In hierarchical-sequential lists you also have to specify in which of the two hierarchy columns the
control column is located. To do this, use one of the SET_*_COLUMN_LEVEL methods in the class
CL_SALV_COLUMN_HIERSEQ.
Control Columns That Contain Information for Any Number of Columns
The cells of this control column contain whole tables:
Each of these tables exclusively refers to cells in the same row of the ALV output.
If this table contains multiple rows, each of these rows controls a specific column of the ALV output.
Every row then contains the name of the column in the ALV output to which the settings refer (in the
graphic below, rows 1 and 2).
If no column name is specified, all columns of the ALV output get the settings (in the graphic below, row 3).
-
For this type of control columns, use the following methods:
Control column Class Method
Column for cell types CL_SALV_COLUMNS_LIST SET_CELL_TYPE_COLUMN
GET_CELL_TYPE_COLUMN
Color column SET_COLOR_COLUMN
GET_COLOR_COLUMN
Hyperlink column SET_HYPERLINK_ENTRY_
COLUMN
GET_HYPERLINK_ENTRY_
COLUMN
Dropdown column SET_DROPDOWN_ENTRY_
COLUMN
GET_DROPDOWN_ENTRY_
COLUMN
Display type
ALV Tool
Classic
ABAP list
Full screen In the
Container
Simple, two-dimensional table Yes Yes Yes
Hierarchical-sequential list Yes
Tree structure No No
In the tree structure you are able to assign colors to nodes or to an individual item.
-
Use Graphic Column
In list-type ALV outputs, you are only able to display icons or symbols in columns that are specifically
defined for this purpose. They may only contain entries that uniquely identify an icon or symbol in your
system.
Display type
ALV Tool
Classic
ABAP list
Full screen In the
Container
Simple, two-dimensional table Yes Yes Yes
Hierarchical-sequential list Yes
Tree structure No No
In the tree structure you can display an icon in any item. To do this, use the method SET_ICON in
the CL_SALV_ITEM class.
Methods
Function Class Method
Defining the column as a icon column CL_SALV_COLUMN_LIST SET_ICON
Check whether the current column is
an icon column
IS_ICON
Define the column as a symbol
column
SET_SYMBOL
Check whether the current column is
an symbol column
IS_SYMBOL
Exception Column
The exception column is a special form of the graphic column:
It displays a status of the current data record with specific icons.
The most common display of exception icons is the traffic light: with the icons and ,
and for example, you are able to display the release status.
As opposed to regular graphic columns, the exception column has additional properties:
The values in the exception column must be between 1 and 5
It can only display a specific set of icons. You are able to choose the icons you wish to display from
several exception groups. In the exception column itself, only the values allowed in this exception group are
available
Users cannot hide the exception column
In list-type ALV outputs, the exception column is always displayed as the first column
-
Display type
ALV Tool
Classic
ABAP list
Full screen In the
Container
Simple, two-dimensional table Yes Yes Yes
Hierarchical-sequential list Yes
Tree structure Yes Yes
Methods
Function Class Method
Specify exception column CL_SALV_COLUMNS_LIST
CL_SALV_COLUMNS_TREE
SET_EXCEPTION_COLUMN
Get exception group GET_EXCEPTION_COLUMN
GET_EXCEPTION_SETTINGS
(Parameter GROUP)
Results rows from aggregations remain empty in the exception column by default. In list-type ALV
outputs, however, you are able to display exception icons. To do this, in the class
CL_SALV_COLUMNS_LIST, use the method SET_EXCEPTION_COLUMN (Parameter
CONDENSED). You check whether the results row is displaying an exception icon using the method
IS_EXCEPTION_CONDENSED or GET_EXCEPTION_SETTINGS
(Parameter CONDENSED).
Columns with Special Function
With some special columns, you control functions that are only useful in very specific situations.
Expansion Column
This column is only available in the hierarchical-sequential list. You use it to specifically display and
hide position rows for specific headers. Here you only check whether an entry in a row of this column is
included: if the cell is empty, only the position rows for the associated header are displayed. If the cell
gets a value, the position rows for the associated header are hidden.
Display type
ALV Tool
Classic
ABAP list
Full screen In the
Container
Simple, two-dimensional table No No No
Hierarchical-sequential list Yes
Tree structure No No
Methods
Function Class Method
Define expansion column CL_SALV_COLUMNS_HIERSEQ SET_EXPAND_COLUMN
-
Get current expansion
column
GET_EXPAND_COLUMN
Text Column for Labels in Results Rows for Intermediate Results
You are able to display intermediate results for aggregations. These intermediate results are displayed
in a special results row in the column the values of which are used in the aggregation. All other columns
in this row are empty by default. You are able to specify a column the values of which are also
transferred to the results row.
Display type
ALV Tool
Classic
ABAP list
Full screen In the
Container
Simple, two-dimensional table Yes Yes Yes
Hierarchical-sequential list Yes
Tree structure No No
Methods
Function Class Method
Define text column CL_SALV_COLUMN_LIST SET_TEXT_COLUMN
Get current text column GET_TEXT_COLUMN
Counter Column to Determine the Number of Rows
You are able to determine and output the number of data records of the ALV output. To do this, you
need a special column, the count column. The rows of this count column never display data. The results
row, however, contains the number of data records.
Display type
ALV Tool
Classic
ABAP list
Full screen In the
Container
Simple, two-dimensional table Yes Yes Yes
Hierarchical-sequential list Yes
Tree structure No No
Methods
Function Class Method
Define count column CL_SALV_COLUMNS_LIST SET_COUNT_COLUMN
Get count column GET_COUNT_COLUMN
Header and Footer Areas of the ALV Output
Definition
You are able to design the areas above and below the ALV output with various elements. To do this, you
use design objects.
-
Various elements are available that you can use to compile a design object. Then you display them at
your desired position.
You need to make various decisions in addition to the design questions:
In which ALV tool and in which display type are you using the design object?
Not all of the options described below are available in every variant.
In which output medium are you using which design object?
You are able to handle the output on the screen and the output in the printout differently.
At which position on the whole ALV output do you want the design objects to appear?
You are able to work with the following positions:
At the top of the whole ALV output (TOP_OF_LIST)
At the bottom of the whole ALV output (END_OF_LIST)
For multiple-page ALV outputs:
At the top of a page (TOP_OF_PAGE)
At the bottom of a page (END_OF_PAGE)
Use
You are able to make the following settings for design objects:
Design Object Compilation
Displaying a Design Object at Top or Bottom of the Whole ALV Output
Displaying a Design Object in Multiple Page ALV Outputs on Every Page
Design Object Compilation
Use
With the design object, you design the area around the ALV output.
You put together a design object from a variety of elements of various types and then display it.
Element Types
You are able to use the following element types:
Header element (header info)
-
Text element with or without label (text label)
Action information
The elements only differ in appearance. No functions are linked with the various element types.
Layout Forms
These elements can be arranged within your design object. To do this, choose between two forms of
layout:
Row-type layout
All elements are lined up in a row.
Table-type layout
You arrange the individual elements in rows and columns.
You are able to combine the two layout forms with one another as you wish, that is, you can insert
rows into a table and vice versa.
Integration
A class is available for each element type:
Classes of element types and layouts
Layout Class
Row-type layout CL_SALV_FORM_LAYOUT_FLOW
Table-type layout CL_SALV_FORM_LAYOUT_GRID
-
Element type Class
Action information CL_SALV_FORM_ACTION_INFO
Header CL_SALV_FORM_HEADER_INFO
Label CL_SALV_FORM_LABEL
Text CL_SALV_FORM_TEXT
Depending on the number of elements in your design object, you proceed differently:
If you only want to display one element, generate the associated object.
If you want to display multiple elements, generate the desired elements with the methods for the row- or
table-type layout elements and specify the desired position within the layout element.
Features
Layout
The following functions are available for the layout forms:
Methods
Function Class Method
Generate an element of
the desired type
CL_SALV_FORM_LAYOUT_
FLOW
CL_SALV_FORM_LAYOUT_
GRID
CREATE_*
Move element SET_ELEMENT
Count elements GET_ELEMENT_COUNT
Link cells CL_SALV_FORM_LAYOUT_
GRID
CREATE_*
SET_ELEMENT
(Parameter COLSPAN bzw.
ROWSPAN)
Hide lines between
columns and rows
SET_GRID_LINES
Get number of columns
and rows
GET_COLUMN_COUNT
GET_ROW_COUNT
Determine which column
contains the labels and
which column contains
the associated texts
SET_COLUMN_LABEL_FOR
Add rows ADD_ROW
Element Types
You have quite similar functions available for the element types:
Methods
-
Function Class Method
Enter text CL_SALV_FORM_ACTION_INFO
CL_SALV_FORM_HEADER_INFO
CL_SALV_FORM_LABEL
CL_SALV_FORM_TEXT
SET_TEXT
Enter tooltip SET_TOOLTIP
Set alignment within a
cell
SET_HORIZONTAL_
ALIGNMENT
GET_HORIZONTAL_
ALIGNMENT
Determine the text
element to which the
label belongs
CL_SALV_FORM_LABEL SET_LABEL_FOR
GET_LABEL_FOR
Example
The following example shows how you display an element of type Text at the end of the ALV output:
...
*... END_OF_LIST
data: lr_text type ref to cl_salv_form_text.
create object lr_text
exporting
text = 'MyText'.
gr_table->set_end_of_list( lr_text ).
...
The following example shows how you insert a design object with a table-type layout at the beginning
of the ALV output:
...
*... TOP_OF_LIST
data: lr_text type ref to cl_salv_form_text.
data: lr_label type ref to cl_salv_form_label.
data: lr_grid type ref to cl_salv_layout_grid.
create object lr_grid.
lr_label = lr_grid->create_label(
text = '1.1 LABEL'
row = 1
column = 1 ).
lr_text = lr_grid->create_text(
text = '1.2 TEXT'
row = 1
column = 2 ).
-
lr_label->set_label_for( lr_text ).
lr_text = lr_grid->create_text(
text = '2.2 TEXT'
row = 2
column = 2 ).
gr_table->set_top_of_list( lr_grid ).
...
Displaying a Design Object for the Complete ALV Output
Use
If you have compiled a design object you are able to display it in various places in your ALV output:
Before or after the ALV output
In ALV Outputs with Multiple Pages at the Beginning or End of Each Page (Page Header or Footer)
This chapter deals with the former design object.
Choosing the Output Medium
If you want to arrange the area above or below the ALV output, you need to decide on the output
medium in which you want to use your design object.
For displaying on a screen (online)
In a printout (print)
Depending on which output type you choose, the design object will have a different appearance.
If you only insert one design object for display on the screen, it will appear on both the screen and the
printout.
If you choose a design object for the display on the screen and another one for the printout, one will
appear on the screen and the other will appear on the printout.
If you only insert a design object for the printout, the design object will only appear in the printout.
What Goes Where?
You are not able to insert all variants of the design object in every ALV tool and in every display type.
The following shows which function is possible in which environment:
Output on the screen above the ALV output
Display type
ALV Tool
Classic ABAP list Full screen In the
Container
Simple, two-dimensional table Yes Yes No
Hierarchical-sequential list Yes
Tree structure Yes Yes
Output on the screen above the ALV output
-
Display type
ALV Tool
Classic ABAP list Full screen In the
Container
Simple, two-dimensional table Yes Yes No
Hierarchical-sequential list Yes
Tree structure Yes No
In the printout, both above and below the ALV output
Display type
ALV Tool
Classic ABAP list Full screen In the
Container
Simple, two-dimensional table Yes Yes Yes
Hierarchical-sequential list Yes
Tree structure No No
Methods
To display the design object on the screen or in the printout, use the following methods:
Function Class Method
Before output, on screen CL_SALV_TABLE
CL_SALV_HIERSEQ_TABLE
CL_SALV_TREE
SET_TOP_OF_LIST
After output, on screen SET_END_OF_LIST
Before output, in printout SET_TOP_OF_LIST_PRINT
After output, in printout SET_END_OF_LIST_PRINT
Displaying Page Headers and Footers
Use
If you have compiled a design object you are able to display it in various places in your ALV output:
Before or after ALV Output
In ALV outputs with multiple pages at the beginning or end of each page (page header or footer)
This chapter deals with the latter design object.
The information on page header and footer is only displayed in the output or the print preview of
your ALV output.
Display type
ALV Tool
Classic ABAP
list
Full screen In the
Container
Simple, two-dimensional table Yes Yes Yes
-
Hierarchical-sequential list Only
TOP_OF_PAGE
Tree structure No No
In contrast to the design object above or below the entire ALV output (TOP_OF_LIST and
END_OF_LIST), the page headers and footers are events: If ALV determines that there is a page
break when generating the printout, the END_OF_PAGE or TOP_OF_PAGE event is triggered. ALV
checks whether a design object is defined for this event and inserts at the correct position.
Features
Both in the TOP_OF_PAGE and in the END_OF_PAGE events, you are able to determine the actual
number of pages using the PAGE parameter.
In the TOP_OF_PAGE event, you are also able to use the TABLE_INDEX parameter to get the table index
of the entry. The table index is displayed on the current page.
In order to be able to display the desired design object in the END_OF_PAGE event, you have to
expressly reserve the required number of lines. To do this, use the method SET_RESERVE_LINES in the
CL_SALV_PRINT class. With the SET_RESERVE_LINES method you determine how many lines are
served.
Special Functions of the Hierarchical-Sequential List
Use
The hierarchical-sequential list allows you to combine two hierarchy levels such as header and position
level in a display. To do this, specify two data tables that have the same data type in at least one column.
You use this column to create a relationship between the two tables.
You are able to generate a maximum of five of such foreign key relationships.
-
In the hierarchical-sequential list, you are able to use the following special functions.
Determining Data Tables for the Header- and Position Level
Linking Data Tables for the Header and Position Level
Displaying or Hiding Position Rows
You use most of the functions of the hierarchical-sequential list analog to the simple, two-dimensional table (such
as aggregation, sorting, filter). Here you also have to specify for which of the hierarchy levels you want
to execute the function.
Features
Linking Data Tables for the Header and Position Level
You are able to link the two internal data tables of the hierarchical-sequential list with up to five
foreign-key relationships.
Methods
Function Class Method
Link data tables CL_SALV_HIERSEQ_
TABLE
FACTORY
(Parameter
T_BINDING_LEVEL1_LEVEL2)
SET_DATA
-
(Parameter T_BINDING)
Get foreign key relationships CL_SALV_HIERSEQ_
LEVEL
GET_BINDING
Displaying or Hiding Position Rows
By default, users cannot hide the position rows of a hierarchical-sequential list: there are no symbols to
enable this function.
You are able to define a column from the header level as an expansion column. This has the following
effects:
You are able to hide or display the position rows of a specific header row using the contents of this
expansion column.
A symbol is displayed in each header row that the user can click to manually hide or display the associated
position rows.
You are able to hide or display the position rows for all header rows simultaneously with your application.
Methods
Function Class Method
Define a column on the
header level as expansion
column
CL_SALV_COLUMNS_
HIERSEQ
SET_EXPAND_COLUMN
Get current expansion
column
GET_EXPAND_COLUMN
Hide position rows for all
header rows
CL_SALV_HIERSEQ_
LEVEL
SET_ITEMS_EXPANDED
Get current status of
position rows
IS_ITEMS_EXPANDED
Special Functions of the Tree Structure
Use
The tree structure is comprised of the following areas:
The Structure
The structureis defined by the initial table that you specify with the FACTORY method. It is displayed by
the column header, which is the top row of the tree structure. Every node in a tree structure has exactly
the structure that is defined in the initial table.
Hierarchy Column
-
The first column of the tree structure is always the hierarchy column. It is not part of the initial table. It
contains symbols that the user can use to display or hide lower levels of a node. Using different icons, you
are able to display whether a node is a branch with subnodes or a leaf.
By default the hierarchy column has no text. However, for each node, you are able to determine which text
is to appear in the hierarchy column.
Nodes
The actual entries in the tree structure are called nodes. Every node has the same structure as the initial
table. Every node is uniquely identified by a key.
A node can either be a leaf or a branch: Branches contain either more branches or leaves that are not
subdivided any further as subnodes.
Item
Items are components of a node: Each node contains exactly as many items as are contained in the initial
table. In this way you are able to compare items with the entries in a column.
Based on the deviating data model, you are able to make some settings to the tree structures that are
not available in the other ALV tools.
You are able to make the following settings for hierarchy column:
Determining Column Header (Section: Determining Wording of the Column Header)
Inserting Icons into the Column Header (Section: Display Icon)
Determining the Tooltip for the Column Header (Section: Determining the Tooltip for the Column Header)
Define text for the node
Determine icons for expanded and collapsed branches
Display leaf as branch
You are able to make the following settings for nodes:
Get node objects
Generate, move and delete nodes
Collapse and expand branches
You are able to make the following settings for items:
Determine value
Set Display of the Item
-
Set selectability
Features
For all of the following functions, this is valid:
Display type
ALV Tool
Classic
ABAP list
Full screen In the
Container
Simple, two-dimensional table No No No
Hierarchical-sequential list No
Tree structure Yes Yes
Get Node Object
Each node is represented by an object of class CL_SALV_NODE, and all of the nodes together are
represented by the object CL_SALV_NODES.
You get the references to the desired node object using various getter methods:
Function Class Method
All nodes together CL_SALV_TREE GET_NODES
List of all node objects and their
key
CL_SALV_NODES GET_ALL_NODES
Specific key GET_NODE
Top node GET_TOP_NODE
List of all subnodes and their key CL_SALV_NODE GET_SUBTREE
GET_CHILDREN
Get key for the node GET_KEY
Related nodes GET_PARENT
GET_FIRST_CHILD
GET_LAST_CHILD
GET_PREVIOUS_SIBLING
GET_NEXT_SIBLING
Generate, Move and Delete Nodes
While you can display whole tables with one command using the ALV tools: simple, two-dimensional
table and a hierarchical-sequential list, with the tree structure, you need to generate the nodes
individually. To do this, provide at least the following:
The contents of the node that you wish to insert.
The new node must have exactly the same structure as is specified in the initial table.
One reference node
Every node is uniquely identified by a key. If there is not yet a node in the tree structure, there will still be
the top node. By default, the top node has an empty character string as the key. You insert the new node at
a position relative to the reference node.
-
The relationship between the new node and the reference node
You are able to insert the new node at one of the following positions relative to the reference node:
Methods
Function Class Method
Add nodes CL_SALV_NODES ADD_NODE
Change top node SET_TOP_NODE
Move node to another position within the tree
structure
CL_SALV_NODE MOVE
Delete node with all of its subnodes DELETE
Delete all nodes of the tree structure CL_SALV_NODES DELETE_ALL
Determine Text in the Hierarchy Column
The hierarchy column is not part of the initial table. This means you are not able to control text in it
with the contents of the data table. You determine the texts in the hierarchy column for each node
individually.
Methods
Function Class Method
Determine text in the hierarchy column CL_SALV_NODE SET_TEXT
Get current text in the hierarchy column GET_TEXT
Determine Icons for Expanded and Collapsed Branches
By default, a node that contains subnodes is indicated by an icon that looks like a folder. The icon looks
different depending on whether the node is expanded or collapsed. You are able to use a different
graphic for each icon. You determine both icons for each icon individually.
Methods
Function Class Method
Set icon for expanded branch CL_SALV_NODE SET_EXPANDED_ICON
-
Set icon for collapsed branch SET_COLLAPSED_ICON
Get icon for expanded branch GET_EXPANDED_ICON
Get icon for collapsed branch GET_COLLAPSED_ICON
Display Leaf as Branch
For reasons of speed, you are able to display a node as a branch even if it does not contain subnodes.
When the user expands the node, you insert the subnodes.
A node that is displayed as a branch although it contains no subnodes is also called an empty folder.
Methods
Function Class Method
Instead of displaying the icon for leaves,
show the icon for a collapsed branch
CL_SALV_NODE SET_FOLDER
Check whether the node is an empty folder IS_FOLDER
Display an expander in the empty folder SET_EXPANDER
Check whether the empty folder has an
expander
HAS_EXPANDER
When the user expands an empty folder, the event EXPAND_EMPTY_FOLDER from the class
CL_SALV_EVENTS_TREE is triggered.
Expand or Collapse Branches or Hide Areas
You are able to expand and collapse the branches of the tree structure individually or together. Beyond
that you are able to make a node or an item completely invisible.
Methods
Function Class Method
Expand individual branch CL_SALV_NODE EXPAND
Collapse individual branch COLLAPSE
Expand all branches CL_SALV_NODES EXPAND_ALL
Collapse all branches COLLAPSE_ALL
Change visibility of a node CL_SALV_NODE SET_VISIBLE
Check whether the node is visible IS_VISIBLE
Change visibility of an item CL_SALV_ITEM SET_VISIBLE
Check whether the item is visible IS_VISIBLE
-
Change the Content of a Node or an Item
While you are modifying the contents of the two ALV tools simple, two-dimensional table and
hierarchical-sequential list by making changes to the transferred table, changes also take place in the
tree structure on the node or item level.
If you exchange the content of the whole node, the structure of the new one must exactly match the
one specified by the initial table.
Methods
Function Class Method
Change content of a node CL_SALV_NODE SET_DATA_ROW
Get content of a node GET_DATA_ROW
Change contents of an item CL_SALV_ITEM SET_VALUE
Get content of an item GET_VALUE
Set Display of the Item
In items of the tree structure you are able to display things other than text. With the type of the item,
you are able to determine that one of the following elements be displayed in it:
Default
Text
Checkbox
Pushbutton
Link
Icon
For the types Checkbox (CHECKBOX), Pushbutton (BUTTON) and Link (LINK), there are events available
to process interactions by the user.
The user can only change the value of checkboxes that are enabled.
Methods
Function Class Method
Set type of an item CL_SALV_ITEM SET_TYPE
Get current type of the item GET_TYPE
Change value of a checkbox SET_CHECKED
Check value of a checkbox IS_CHECKED
Enable checkbox so that the user can SET_EDITABLE
-
change the value interactively
Check whether a checkbox is enabled IS_EDITABLE
Insert icon SET_ICON
Get icon GET_ICON
To display an icon in an item, proceed as follows:
You assign the type Default (DEFAULT) to the item
You ensure that the content of the item is a permitted indicator for the desired icon (for
example @AB@)
Use the method SET_ICON in the CL_SALV_ITEM class.
When the user changes the value of a checkbox, the event CHECKBOX_CHANGE from
the class CL_SALV_EVENTS_TREE is triggered.
If the user clicks on an item of type Pushbutton (BUTTON) or Link (LINK), the event
LINK_CLICK from the class CL_SALV_EVENTS_TREE is triggered.
Set Selectability of an Item
By default, the user is able to select an item by clicking on it or by pressing the tab key. You are able to
determine that users cannot select an item.
Methods
Function Class Method
Set selectability of an item CL_SALV_ITEM SET_ENABLED
Check selectability IS_ENABLED
Basic ALV Functions
In the broadest sense, basic ALV functions are functions that you can also provide the user as generic ALV
functions. However, because you do not change all of these functions using the ALV object model, which
means that you would be able to trigger them with your application, basic ALV functions are limited here
to those that you can program yourself:
Sort
Filter
Perform Aggregations
Enable Layouts
-
Selection
Sorting by Columns
Use
You are able to change the sequence of data records according to specific rules by sorting the ALV
output. You specify which column includes the value that is to be sorted alphabetically or numerically,
determining the sequence of all rows.
You are able to specify up to nine columns that can be used to sort the ALV output.
Control Level
Data records have the same value in a sorted column for a control level. If this value changes in regard
to the next data record, it is called a control level change.
You have various options to highlight a control level change.
Integration
The sort settings for a column are represented by an object of type CL_SALV_SORT. The total of all the
sort objects is represented by an object of type CL_SALV_SORTS.
You are able to make calculations using the values of numeric columns. By default all values of a column are
used for this. If you need intermediate results in addition to the overall result of the calculation, the rows
that contain the subvalues of an intermediate result need to be next to each other: They sort the ALV
output. The sort is then a prerequisite for ALV being able to determine and display intermediate results.
Features
You are able to make the following settings for sorting:
Get sort objects
Create and delete sort objects
Set sort direction
Set column sequence of sorting
Forbid changes
Highlight control level change
For all of the following functions, this is valid:
Display type
ALV Tool
Classic
ABAP list
Full screen In the
Container
Simple, two-dimensional table Yes Yes Yes
Hierarchical-sequential list Yes
Tree structure No No
Get Sort Objects
In every main ALV class where sorting is possible, the GET_SORTS method exists. This method returns
the sort objects for all columns in the ALV output (class CL_SALV_SORTS). Using this object with the
methods GET or GET_SORT you get the sort object for the desired column.
-
Methods
Function Class Method
Get SORTS
object
CL_SALV_TABLE
CL_SALV_HIERSEQ_TABLE
GET_SORTS
Get all sort
objects
CL_SALV_SORTS GET
Get all sort
objects for a
hierarchy level
CL_SALV_HIERSEQ_LEVEL GET_SORTS
Get a specific
sort object
CL_SALV_SORTS GET_SORT
Check whether a
column is sorted
(a sort object
exists)
IS_SORT_DEFINED
Create and Delete Sort Objects
You are able to create a maximum of one sort object for a column You are able to sort the ALV output
using up to nine columns.
You are able to delete sort objects either individually or all at once.
Methods
Function Class Method
Create sort object CL_SALV_SORTS ADD_SORT
Delete individual sort object REMOVE_SORT
Delete all sort objects CLEAR
If you assign a new data table with a new structure to your ALV output, all aggregation objects will
be deleted automatically.
Set Sort Direction
For each individual sort object, you are able to determine whether you want to sort the column
ascending (for example a, b, c) or descending (for example c, b, a): You set the sort direction.
Methods
Function Class Method
Set sort Direction CL_SALV_SORTS ADD_SORT (Parameter
SEQUENCE)
-
CL_SALV_SORT SET_SEQUENCE
Get sort direction CL_SALV_SORT GET_SEQUENCE
Set Column Sequence of Sorting
If you sort the ALV output by multiple columns, the result changes depending on the sequence of
columns that is used to sort.
By default, the columns are sorted in the sequence in which you generated your sort objects. You are
able to change this sequence.
Methods
Function Class Method
Change column
sequence of sorting
CL_SALV_SORTS ADD_SORT (Parameter
POSITION)
SET_POSITION
Forbid Changes
By default, the user can change sort settings that you have specified using the application. However,
you are able to expressly forbid this.
Methods
Function Class Method
Forbid changes to sort object CL_SALV_SORTS ADD_SORT
(Parameter
OBLIGATORY)
CL_SALV_SORT SET_OBLIGATORY
Check whether user is able to
make changes to the sort object
CL_SALV_SORT IS_OBLIGATORY
Highlight Control Level Change
If a value changes in a sorted column between two data records, this is called a control level change.
You are able to highlight the control level change in two ways:
You separate the group levels with a horizontal line.
You start a new page for each control level.
Prerequisite
You have activated grouping of the ALV output.
Meth