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 hierarchicalsequential 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 (siblingsibling 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
Classic ABAP list
Full screen
In the Containe r
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-sequential list
Yes
No
No
ALV Tool
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
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-sequential list
No Yes
Ja
ALV Tool
Tree structure
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
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
Display type
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
GET_AGGREGATIONS
CL_SALV_AGGREGATIONS
GET_COLUMNS
CL_SALV_COLUMNS_TABLE or CL_SALV_COLUMNS_HIERSEQ or
Remarks
CL_SALV_COLUMNS_TREE GET_DISPLAY_SETTINGS
CL_SALV_DISPLAY_SETTINGS
GET_EVENT
CL_SALV_EVENTS_TABLE or CL_SALV_EVENTS_HIERSEQ or
Not in CL_SALV_TREE
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
Classic ABAP list
Full screen
In the Container
Simple, twodimensional table
Yes
Yes
Yes
Hierarchicalsequential list
Yes Yes
Yes
ALV Tool
Tree structure
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, twodimensional table
T_TABLE
Table for structure and contents of the ALV output
Hierarchicalsequential 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
T_TABLE
Initial table Empty table, only sets the structure
Tree 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 Simple, twodimensional table
Classic ABAP list
Full screen
In the Container
Yes
No
No
Hierarchicalsequential 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
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-sequential list
Yes No
No
ALV Tool
Tree structure 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
SET_DATA
CL_SALV_HIERSEQ_LEVEL
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
(in CL_SALV_HIERSEQ_LEVEL) Tree structure
T_TABLE
New table of hierarchy level
T_BINDING
List of up to five foreign-key relationships
VALUE
New table of hierarchy level
T_BINDING
List of up to five foreign-key relationships
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
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-sequential list
Yes Yes
No
ALV Tool
Tree structure 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
Get current title
SET_HEADER 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
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
No
Only above the ALV output
Yes
Hierarchical-sequential list
No No
No
ALV Tool
Tree structure 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
GET_COLUMNS
CL_SALV_HIERSEQ_TABLE CL_SALV_TREE 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 user’s 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 user’s column set. Display type
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-sequential list
Yes Yes
Yes
ALV Tool
Tree structure 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
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-sequential list
Yes Yes
Yes
ALV Tool
Tree structure
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
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-sequential list
Yes Yes
Yes
ALV Tool
Tree structure 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 Change DDIC reference for
GET_DDIC_REFERENCE CL_SALV_COLUMNS
APPLY_DDIC_STRUCTURE
several columns
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
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-sequential list
Yes Yes
Yes
ALV Tool
Tree structure 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
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-sequential list
Yes No
No
ALV Tool
Tree structure 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
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
No
No
Yes
Hierarchical-sequential list
No No
No
ALV Tool
Tree structure 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
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-sequential list
Yes Yes
Yes
ALV Tool
Tree structure
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 Set tooltip for hierarchy column of a tree structure
GET_TOOLTIP 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
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
No
No
No
Hierarchical-sequential list
No Yes
Yes
ALV Tool
Tree structure 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 user’s 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
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-sequential list
Yes No
No
ALV Tool
Tree structure 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
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-sequential list
Yes Yes
Yes
ALV Tool
Tree structure
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
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-sequential list
Yes No
No
ALV Tool
Tree structure
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
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-sequential list
Yes No
No
ALV Tool
Tree structure
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
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-sequential list
Yes Yes
Yes
ALV Tool
Tree structure Methods
Function
Class
Method
Specify exception column
CL_SALV_COLUMNS_LIST
SET_EXCEPTION_COLUMN
Get exception group
CL_SALV_COLUMNS_TREE
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
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
No
No
No
Hierarchical-sequential list
Yes No
No
ALV Tool
Tree structure 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
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-sequential list
Yes No
No
ALV Tool
Tree structure 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
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-sequential list
Yes No
No
ALV Tool
Tree structure 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
CREATE_*
Move element
CL_SALV_FORM_LAYOUT_
SET_ELEMENT
Count elements
GRID
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
Determine which column contains the labels and which column contains the associated texts
SET_COLUMN_LABEL_FOR
Add rows
ADD_ROW
GET_ROW_COUNT
Element Types You have quite similar functions available for the element types: Methods Function
Class
Method
Enter text
CL_SALV_FORM_ACTION_INFO
SET_TEXT
Enter tooltip
CL_SALV_FORM_HEADER_INFO
SET_TOOLTIP
Set alignment within a cell
CL_SALV_FORM_LABEL
SET_HORIZONTAL_ ALIGNMENT
CL_SALV_FORM_TEXT
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
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
No
Hierarchical-sequential list
Yes Yes
Yes
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
No
Hierarchical-sequential list
Yes Yes
No
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-sequential list
Yes No
No
ALV Tool
Tree structure Output on the screen above the ALV output Display type ALV Tool
Tree structure In the printout, both above and below the ALV output Display type ALV Tool
Tree structure 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
SET_TOP_OF_LIST
After output, on screen
CL_SALV_HIERSEQ_TABLE
SET_END_OF_LIST
Before output, in printout
CL_SALV_TREE
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 Simple, two-dimensional table Hierarchical-sequential list
Classic ABAP list
Full screen
In the Container
Yes
Yes
Yes
No
No
Only TOP_OF_PAGE
Tree structure
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_
GET_BINDING
LEVEL 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 Hide position rows for all header rows
GET_EXPAND_COLUMN CL_SALV_HIERSEQ_ LEVEL
Get current status of position rows
SET_ITEMS_EXPANDED 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
Hierarchical-sequential list
No
Tree structure
No
No
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
Delete node with all of its subnodes Delete all nodes of the tree structure
MOVE DELETE
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
Collapse all branches
EXPAND_ALL COLLAPSE_ALL
Change visibility of a node
CL_SALV_NODE
Check whether the node is visible Change visibility of an item
SET_VISIBLE IS_VISIBLE
CL_SALV_ITEM
Check whether the item is visible
SET_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 Change contents of an item Get content of an item
GET_DATA_ROW CL_SALV_ITEM
SET_VALUE 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 change the value interactively
SET_EDITABLE
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 Simple, table
Classic ABAP list
Full screen
In the Container
Yes
Yes
Yes
No
No
two-dimensional
Hierarchical-sequential list
Yes
Tree structure 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 object
CL_SALV_TABLE
GET_SORTS
SORTS
CL_SALV_HIERSEQ_TABLE
Get all objects
sort
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
CL_SALV_SORT
GET_SEQUENCE
Get sort direction
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 POSITION)
(Parameter
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
CL_SALV_SORT
IS_OBLIGATORY
Check whether user is able to make changes to the sort object
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.
Methods
Function
Class
Method
Activate grouping of the ALV output
CL_SALV_SORTS
SET_GROUP_ACTIVE
Check whether grouping of the ALV output has been activated.
IS_GROUP_ACTIVE
Set display change
ADD_SORT (Parameter GROUP)
of
control
level CL_SALV_SORT
Get display of the control level change
SET_GROUP GET_GROUP
Filter Data Rows Use With filters you restrict the display of data records in the ALV output. To do this, you specify conditions that a record in a specific column has to fulfill in order to be displayed or filtered out. Like the sort object, you are able to generate a maximum of one filter object for each column. Every filter object can include on or more filter conditions. Classes The total of all the filter objects is represented by an object of type CL_SALV_FILTERS. The filter settings for a column are represented by an object of type CL_SALV_FILTER. The individual filter conditions in a filter object are represented by objects of type CL_SALV_SELOPT.
Filter Condition In a filter condition, you provide information on which data records are to be displayed: •
The column in which the tested content is located
•
The comparison value with which the rows are tested. This can be an individual value or an range for the given value.
•
The condition, that is, an operator that defines the necessary relation between the cell value and the comparison value (for example, greater than, less than or equal to)
•
Exclusion or inclusion, that is, whether the rows that fit the condition are to be displayed or whether they are not to be displayed
All entries that have the value AA in the CARRID column should be displayed. ...
gr_filter->add_filter( columnname = 'CARRID' sign = 'I' option = 'EQ' low = 'AA' ). ...
With the columname parameter, you determine the column name With the low (or high) parameter, you determine the comparison value With the option parameter, you determine the condition With the sign parameter, you determine whether it is an inclusive or exclusive
condition Features You are able to make the following settings for aggregations: •
Get filter objects and filter conditions
•
Generate and Delete a filter object and filter condition
•
Forbid filters for a column
The following is valid for all of these functions: Display type
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-sequential list
Yes No
No
ALV Tool
Tree structure Get Filter Objects and Filter Conditions
The GET_FILTERS method exists in each ALV main class in which filtering is possible. It returns the FILTERS object of the ALV output (all filter objects for the column). Using this FILTERS object with the methods GET or GET_FILTER, you get the filter object for the desired column, as long as one exists there. You also get the filter conditions using the filter object. Methods Function
Class
Method
Get FILTERS object
CL_SALV_TABLE
GET_FILTERS
CL_SALV_HIERSEQ_TABLE Get all filter objects
CL_SALV_FILTERS
GET
Get all filter objects for a hierarchy level
CL_SALV_HIERSEQ_LEVEL
GET_FILTERS
Get specific filter object
CL_SALV_FILTERS
GET_FILTER
Check whether a column is filtered (a filter object exists) Get all filter conditions for a filter object
IS_FILTER_DEFINED CL_SALV_FILTER
GET
Generate and Delete a Filter Object and Filter Condition You are able to create a maximum of one filter object for a column. However, you are able to create any number of filter conditions for each filter object. You are able to delete filter objects either individually or all at once. The filter conditions for a filter object can only be deleted all at once.
You are only able to generate a filter object for columns in which you have not expressly forbid this (see the Forbidding Filters for a Column). Defining a Filter Condition When you define the first filter object for a column a filter condition is automatically generated. You make the settings for this using the parameters for the method ADD_FILTER. You create all further filter conditions for the same column using the ADD_SELOPT method. You manage all information for the filter conditions using the methods of class CL_SALV_SELOPT. Methods Function
Class
Method
Generate filter object
CL_SALV_FILTERS
ADD_FILTER
Delete individual filter object
REMOVE_FILTER
Delete all filter objects
CLEAR
Generate filter condition
CL_SALV_FILTER
Delete all filter conditions
ADD_SELOPT CLEAR
Determine comparison value or area
CL_SALV_SELOPT
SET_LOW SET_HIGH
Get comparison value
GET_LOW GET_HIGH
Define condition (operator)
SET_OPTION
Get condition (operator)
GET_OPTION
Determine inclusion or exclusion
SET_SIGN
Get inclusion or exclusion
GET_SIGN
If you assign a new data table with a new structure to your ALV output, all filter objects will be deleted automatically. Forbid Filters for a Column By default you or the user is able to define a filter for every column. For each column you can determine whether a filter object can be defined for it. Methods Function
Class
Method
Forbid filters for a column
CL_SALV_FILTERS
SET_FILTER_ALLOWED
Check whether filters are forbidden for a column
IS_FILTER_ALLOWED
Making Calculations (Aggregation) Use You are able to make calculations in columns with a numeric data type: You generate an aggregation object. The result of the calculation is then displayed in a separate results row. Intermediate Results Usually all values in a column are used in a calculation during aggregation. You are also able to obtain intermediate results. To do this you have to sort the ALV output and group the rows that you want to use for the intermediate result. Prerequisites The column that you are aggregating has a numeric data type. Features You are able to make the following settings for aggregations: •
General Settings for the Aggregation Object
•
Settings for the Results Rows
•
Settings for Intermediate Results
Make Settings for Aggregation Use You are able to make various settings for the calculation of columns. The following types of calculation are available: •
Total Adds all values for the column
•
Minimum Determines the smallest value for the column
•
Maximum Determines the largest value for the column
•
Average Determines the geometric average of all values in the column
You are able to create a maximum of one calculation for every column. The result of the calculation is then displayed in a separate Results Row. The settings for calculations (aggregation settings) for a column are represented by an object of type CL_SALV_AGGREGATION. The total of all the aggregation objects is represented by an object of type CL_SALV_AGGREGATIONS.
In addition to the calculation types listed above, you are also able to determine the total data records (see also Columns with Special Technical Meaning, the section on Counter Column to Determine Number of Rows). The result is displayed in the results row. The row count, however, is not represented by an aggregation object. Features You are able to make the following settings for aggregations: •
Getting Aggregation Object
•
Creating and Deleting Aggregation Object
•
Determine the Type of Aggregation
•
Determining the Position of the Results Row
•
Allow and Forbid Aggregation
•
The following is valid for all of these functions: Display type
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-sequential list
Yes Yes
Yes
ALV Tool
Tree structure Getting Aggregation Object
The GET_AGGREGATIONS method, which returns all aggregation objects of the ALV output (class CL_SALV_AGGREGATIONS), exists in every main ALV class. Using this object with the methods GET or GET_AGGREGATION, you get the aggregation object for the desired column. Methods Function
Class
Method
Get AGGREGATIONS object
CL_SALV_TABLE
GET_AGGREGATIONS
CL_SALV_HIERSEQ_TABLE CL_SALV_TREE Get AGGREGATIONS object for a hierarchy level
CL_SALV_HIERSEQ_LEVEL
GET_AGGREGATIONS
Get all aggregation objects
CL_SALV_AGGREGATIONS
GET
Get a specific aggregation object
GET_AGGREGATION
Check whether a column will be calculated (has an aggregation object)
IS_AGGREGATION_ DEFINED
Creating and Deleting Aggregation Object You are able to create a maximum of one aggregation object for a column You are able to delete aggregation objects either individually or all at once. You can also delete the settings for an aggregation object without deleting the aggregation object itself.
By default, columns with the numeric text (NUMC or n) data type cannot be aggregated. In these types of columns, you can only create an aggregation object if you expressly permit this. You can also only forbid aggregation for columns that can be aggregated. Methods Function
Class
Method
Create an aggregation object
CL_SALV_AGGREGATIONS
ADD_AGGREGATION
Delete individual aggregation object
REMOVE_AGGREGATION
Delete all aggregation objects
CLEAR
Delete aggregation settings for an aggregation object
CL_SALV_AGGREGATION
CLEAR
If you assign a new data table with a new structure to your ALV output, all aggregation objects will be deleted automatically. Specifying the Type of Aggregation For an aggregation object, you specify - in addition to the column name - which type of calculation you wish to make with it: you set the type of aggregation object. Methods Function
Class
Method
Set aggregation type
CL_SALV_AGGREGATIONS
ADD_AGGREGATION (Parameter AGGREGATION)
CL_SALV_AGGREGATION
SET
CL_SALV_AGGREGATION
GET
Get aggregation type
Allow and Forbid Aggregation By default, all columns with a numeric data type can be aggregated with the exception of columns of data type NUMC. You are able to set whether a column can be aggregated as follows: •
In columns that actually have a suitable data type, forbid aggregation
•
In columns of data type numeric text, you expressly allow aggregation
Methods Function
Class
Method
Forbid aggregation in suitable columns
CL_SALV_AGGREGATIONS
SET_AGGREGATION_ ALLOWED
Check whether aggregation is allowed in suitable columns
IS_AGGREGATION_ ALLOWED
Allow aggregation in numeric text
SET_NUMERICAL_ AGGREGATION
Check whether aggregation is allowed in numeric text
IS_NUMERICAL_ AGGREGATION_ON
Results Rows Definition You are able to perform various calculations for numeric columns in the ALV output and then display them in a results row. You are also able to sort the data records according to specific criteria and generate the intermediate results for each calculation. These intermediate results are also displayed in the results row.
Beyond the options described here, you are not able to affect the content and appearance of the results row. Use You are able to make the following settings for results rows: •
Determining the Position of the Results Row
•
Displaying the Labels for Intermediate Results in the Results Row (Section Columns with Special Functions)
•
Displaying Exception Icons in the Results Row of the Intermediate Results (Section Using Graphic Columns,
Exception Column) Determining the Position of the Results Row You are able to define whether you wish to display the results row for the calculations in an ALV output above or below the rows that are included in the calculation. Display type
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-sequential list
Yes Yes
Yes
ALV Tool
Tree structure Methods Function
Class
Method
Determining the position of the results row
CL_SALV_AGGREGATIONS
SET_AGGREGATION_ BEFORE_ITEMS
Check where the results rows are located
IS_AGGREGATION_ BEFORE_ITEMS
Generating Intermediate Results Use By default all values in a column are used in the calculation during aggregation. However, you are also able to generate intermediate results. You group the data records that contain the values for an intermediate result and display each intermediate result in its own results row.
You are also able to generate aggregations in and display intermediate results in the tree structure. However, here the intermediate results are automatically generated from the values of the subnodes in every node that has subnodes. The following information is thus only valid for the simple, twodimensional table and the hierarchical-sequential list. To generate intermediate results you have to provide certain information: •
To specify in which column the values from which the intermediate results are calculated are located, generate an aggregation object for the desired column. The overall result is displayed in the results row.
•
To specify which data records are contained in an intermediate result, group the data records: You sort the ALV output by the column that includes the criterion for the intermediate result.
•
To then display the intermediate results, you calculate the intermediate results using the column with the criterion.
The most common way of generating intermediate results is to use subtotals. That is way you often find this term in place of intermediate results for all aggregation types. Nevertheless you can of course generate intermediate results (or “subtotals”) for all other aggregation types. Prerequisites •
You have generated an aggregation object for at least one aggregatable column.
•
The column with the criterion for intermediate results is a column that cannot be aggregated.
•
You are able to generate intermediate results for up to nine columns. Features
You are able to make the following settings for intermediate results: •
Generating Intermediate Results
•
Hide Subvalues of Intermediate Results
•
Determining the Position of the Results Row
•
Displaying the Labels for Intermediate Results in the Results Row (Section Columns with Special Functions)
•
Displaying Exception Icons in the Results Row of the Intermediate Results (Section Using Graphic Columns,
Exception Column) For all of the following functions, this is valid: Display type
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-sequential list
Yes No
No
ALV Tool
Tree structure Generating Intermediate Results
To display intermediate results in a column that already has an aggregation object, use the sort object from another column.
The column that contains the sort object has to have one of the following data types:
alphanumeric data type
or
Numeric text (NUMC or n), assuming you have not expressly permitted
aggregation for this data type (see chapter Making Settings for Aggregation , Section Allow and Forbid Aggregation) Methods Function
Class
Method
Generating intermediate results
CL_SALV_SORTS
ADD_SORT (Parameter SUBTOTAL)
CL_SALV_SORT
SET_SUBTOTAL
CL_SALV_SORT
IS_SUBTOTALLED
Check whether intermediate results are generated for a specific column
Hide Subvalues of Intermediate Results You are able to hide the data records that form the subvalues of an intermediate result. To do this, specify the column that contains the criteria for the intermediate results, not the column that contains the calculated values. Methods Function
Class
Method
Hide subvalues of intermediate results
CL_SALV_SORTS
SET_COMPRESSED_SUBTOTAL
Get column that only displays results rows Check whether the rows for an intermediate result are hidden or displayed
GET_COMPRESSED_SUBTOTAL CL_SALV_SORT
IS_SUBTOTAL_COMPRESSED
Settings Management in Layouts Use In a layout, users are able to save information on column structure, sorting criteria, filter conditions and various display options, and so on. In this way, they are able to display their ALV outputs with the same properties every time. You are able to use your application to affect the options that users have for using layouts.
You are not able to use the ALV object model to either create or delete layouts. User-Specific Layout in Contrast to Layout for All Users Layouts can be available to only one user or for all users of your application. Depending on that, the layout is designated as either a user-specific layout or a layout for all users. You are able to determine whether users are allowed to save user-specific layouts or whether they
are authorized to save layouts for all users as well.
User-specific layouts and layouts for all users also differ in their names:
The names of user-specific layouts start with a letter (A-Z). The names of layouts for all users start with '/'. The names of standard layouts provided by SAP start with a number (0-9).
Layout Key All layouts for all applications are saved centrally. To enable a layout to be assigned to your application, set a layout key. All layouts that users save to your application can then be identified with this layout key and a name. Features You are able to make the following settings for layouts: •
Get layouts
•
Set layout key
•
Determine for whom users can save layouts
•
Change layout for start of the ALV output
•
Display dialog box for layout
The following is valid for all of these functions: Display type
Classic ABAP list
Full screen
In the Container
Simple, twodimensional table
Yes
Yes
Yes
Hierarchicalsequential list
Yes Yes
Yes
ALV Tool
Tree structure Get Layouts
You are able to get the settings for layouts that users have saved for your application. Methods Function
Class
Method
Get layout object
CL_SALV_TABLE
GET_LAYOUT
CL_SALV_HIERSEQ_TABLE CL_SALV_TREE Get settings individual layouts
for
CL_SALV_LAYOUT
Get current layout
GET_LAYOUTS GET_CURRENT_LAYOUT
Set Layout Key The layout key is a prerequisite for users are able to save a layout to your application. The layout key includes the following information: •
Name of the application
•
A key that uniquely identifies the output table within your application
•
A logical group for further specification (for example with multiple ALV instances in one program)
Methods Function
Class
Method
Set layout key
CL_SALV_LAYOUT
SET_KEY
Get layout key
GET_KEY
Determine for Whom Users Can Save Layouts By default, users are not able to save layouts. You are able to determine whether users can save layouts •
Only for themselves (user-specific)
•
Only for other users (for all users)
•
For both themselves and for other users
Methods Function
Class
Method
Determine for whom users can save layouts
CL_SALV_LAYOUT
SET_SAVE_RESTRICTION
Check for whom users can save layouts
GET_SAVE_RESTRICTION
Change Layout for Start of the ALV Output You have to ways of changing which layout will be used when the ALV output is started: •
You allow the user to set one of the layouts as default. Depending on whether users choose a user-specific layout or one that is available to all users, the default is only valid for the user himself or for all users of the application.
•
You define a layout as initial layout. In this way, you override any defaults set up by the user.
Methods Function
Class
Method
Allow defaults
CL_SALV_LAYOUT
SET_DEFAULT
Get layout that was set by a user as a default
GET_DEFAULT_LAYOUT
Checks whether the user has set a layout as default
HAS_DEFAULT
Set initial layout
SET_INITIAL_LAYOUT
Get initial layout
GET_INITIAL_LAYOUT
Display Dialog Box for Layout You are able to display a dialog box that provides the user with a selection of layouts that are saved for your application. Methods Function
Class
Method
Display dialog box
CL_SALV_LAYOUT
F4_LAYOUTS
Selecting Cells, Rows and Columns Use You are able to use your application to determine which areas are selected when the ALV output is being displayed. In the simple, two-dimensional table and hierarchical-sequential list, you are also able to change whether and under what conditions users are able to select areas of the ALV output. To do this, use the selection type in list-type ALV outputs. In tree structures, you determine whether each individual node or item can be selected or not. Current Cell The current cell indicates the position of the cursor in the simple, two-dimensional table and the hierarchical-sequential list. The current cell is highlighted differently from the selected cells. In this way you are able to recognize the current cell when you are in a selected area. Features You can make the following settings for the selection in the ALV output: •
Get settings for selection and information on the selected areas
•
Set selection type
•
Enable selection of nodes and items
•
Select area Get Information on Selections
The method GET_SELECTIONS that returns the selection object exists in each main ALV class. With this object, you get the desired information with various getter methods. Methods Function
Class
Method
Get selection object
CL_SALV_TABLE CL_SALV_HIERSEQ_TABLE
GET_SELECTIONS
CL_SALV_TREE Get a selection object for a hierarchy level
CL_SALV_HIERSEQ_LEVEL
GET_SELECTIONS
Set Selection Type With the selection type, you set which cells users are able to select simultaneously, that is, whether and how they can combine the selections. The selection type has different effects in the various display types. Display type
Classic ABAP list
Full screen
In the Container
Simple, twodimensional table
Yes
Yes
Yes
Hierarchicalsequential list
Yes
ALV Tool
Tree structure
No
No
The following selection types are available: •
NONE
•
SINGLE
•
MULTIPLE
•
ROW_COLUMN
•
CELL
The following table shows which selection type you have to assign to the ALV output to enable users to execute the desired function. Required Selection Type Desired Function
Classic ABAP List Hier.-Seq. List
Full screen Container
Select individual column
NONE
NONE
Select individual row
SINGLE
NONE
Select individual cell
NONE
CELL
Select multiple cells (with CTRL or shift key)
Not possible
CELL
Select one or multiple rows and one or more columns (with CTRL key)
SINGLE
MULTIPLE ROW_COLUMN
Provide pushbutton or checkbox to select rows
SINGLE
CELL ROW_COLUMN CELL
Methods Function
Class
Method
Set Selection Type
CL_SALV_SELECTIONS
SET_SELECTION_MODE
Get selection type
GET_SELECTION_MODE
Enable Selection of Nodes and Items In the tree structure, you can determine whether the user is allowed to select individual nodes or items. Display type
Classic ABAP list
Full screen
In the Container
Simple, twodimensional table
No
No
No
Hierarchicalsequential list
No Yes
Yes
ALV Tool
Tree structure Methods Function
Class
Method
Set selectability of the item
CL_SALV_ITEM
SET_ENABLED
Check whether the item can be selected Markierbarkeit festlegen
des
Knotens
IS_ENABLED CL_SALV_NODE
Check whether the node can be selected
SET_ENABLED IS_ENABLED
Select Area You are able to set selections in the ALV output using your application. Display type
Classic ABAP list
Full screen
In the Container
Simple, twodimensional table
Yes
Yes
Yes
Hierarchicalsequential list
Yes Yes
Yes
ALV Tool
Tree structure Methods Function
Class
Method
Set current cell
CL_SALV_SELECTIONS
SET_CURRENT_CELL
Get current cell
GET_CURRENT_CELL
Select cells
SET_SELECTED_CELLS
Get selected cells
GET_SELECTED_CELLS
Select rows
SET_SELECTED_ROWS
Get selected rows
GET_SELECTED_ROWS
Select columns
CL_SALV_SELECTIONS
SET_SELECTED_COLUMNS
Get columns
CL_SALV_SELECTIONS_TREE
GET_SELECTED_COLUMNS
CL_SALV_SELECTIONS_TREE
SET_SELECTED_NODES
selected
Select node Get selected nodes
GET_SELECTED_NODES
Select item
SET_SELECTED_ITEM
Get selected item
GET_SELECTED_ITEM
Determining the Appearance of the ALV Output You can change the appearance of the ALV output in various ways. The options are mainly restricted by the Display Type in which you are displaying the ALV output.
You are only able to change the font in full-screen display or in display in a container, not in the classic ABAP list. You can make the following settings for the appearance of the ALV output: •
Defining Colors for Columns, Rows and Cells
•
Setting Text Properties
•
Hiding Lines Between Columns and Rows
•
Changing the Display of Numeric Values
•
Determining Column Width
•
Arranging a Data Record in Multiple Rows
•
Designing Header and Footer Areas of the ALV Output
Color Definition for Columns, Rows and Cells Use You are able to assign different colors to the columns, rows and cells of your ALV output table. A set of colors is available for this purpose that you can use with few restrictions. Text Color, Background Color, Intensity and Inverse Display The various ALV tools use different concepts when dealing with color: •
In the tree structure, some fixed combinations of text and background color are available. Colors in the Tree Structure
•
Text Color
Background Color
Technical Name
Black
Standard
DEFAULT
Black
Light yellow
EMPHASIZED
Black
Medium blue
EMPHASIZED_A
Black
Light blue
EMPHASIZED_B
Black
Salmon colored
EMPHASIZED_C
Black
Red
EMPHASIZED_NEGATIVE
Black
Green
EMPHASIZED_POSITIVE
Gray
Standard
INACTIVE
Dark blue
Standard
INTENSIFIED
Dark red
Standard
INTENSIFIED_CRITICAL
In both of the other tools you are able to change the combinations of text and background color to a certain degree:
You choose a color from a set of possible colors.
You determine whether this color is to be light or dark (intensity)
You determine whether the color applies to the background or the text (inverse
display) Colors in List-Type ALV Outputs Color
Technical Name
GUI dependent
COL_BACKGROUND
Gray blue
COL_HEADING
Light gray
COL_NORMAL
Yellow
COL_TOTAL
Blue green
COL_KEY
Green
COL_POSITIVE
Red
COL_NEGATIVE
Orange
COL_GROUP
The color COL_KEY is the color that the system uses for Lead Columns. Features You are able to make the following settings for colors: •
Lead Columns have a color determined by the system. In lead columns you are only able to change the color
in individual cells. •
In list-type ALV outputs, you are able to color in rows or cells using the Color Column. You color in whole columns by changing the color property of the column. In the tree structure, however, you can color in nodes and items directly using the associated methods. You are not able to color in columns here.
•
You can present the entire ALV output with stripes, that is automatically color in the rows of the ALV output alternating light and dark. Changing the Color of Columns
The color is a property of the column. You can change them directly this way.
You are only able to change the color of a column if it is not a lead column. Display type
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-sequential list
Yes No
No
ALV Tool
Tree structure Methods Function
Class
Method
Change the color of a column
CL_SALV_COLUMN_LIST
SET_COLOR
Get the color of a column
GET_COLOR
Change Color of Nodes and Items In the tree structure, the color is the property of each node or individual item. Display type
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
No
No
No
Hierarchical-sequential list
No Yes
Yes
ALV Tool
Tree structure Methods
Function
Class
Method
Change color combination for node
CL_SALV_NODE
SET_ROW_STYLE
Get color combination for node Change color combination for item
GET_ROW_STYLE CL_SALV_ITEM
Get color combination for item
SET_STYLE GET_STYLE
Display Rows with Stripes You are able to color the rows of the ALV output alternating light and dark.
The colors for both shades are defined by the system and you cannot change them. Display type
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-sequential list
Yes No
No
ALV Tool
Tree structure Methods Function
Class
Method
Set striped pattern
CL_SALV_DISPLAY_SETTINGS
SET_STRIPED_PATTERN
Check whether the striped pattern is set
IS_STRIPED_PATTERN
Setting Text Properties Use You are able to change the display of text in the ALV output. Depending on whether the text is located in the ALV output itself or in the header of the list, for example, you have different options.
The following sections mainly deal with how you change the display of alphanumeric columns. With numeric columns there are additional options. For more information about this, see changing the display of numeric values.
Features You are able to make the following settings for text properties: •
Set font
•
Set alignment of the text in the column
•
Determine lowercase and uppercase
•
Determining display of empty cells
•
Changing text color
Set Font You are able to change the font of text in the design object (header and footer area of page or list) and in the tree structure. Font in Design Object In the classic ABAP list, the various element types that you are able to use in a design object differ in the font. In the other two display types they differ in font, font size and font color. The following graphic provides a comparison of the fonts as they are set in the various display types for the ALV output for the four element types.
This is how you set the font in the design object using a choice of element type. Font in the Tree Structure You are able to choose between three fonts in each item: •
Standard font
•
A non-proportional font (all characters require the same amount of space)
•
A proportional font (characters have different widths) Display type
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
No
No
No
Hierarchical-sequential list
No Yes
Yes
ALV Tool
Tree structure Methods Function
Class
Method
Set font of an item
CL_SALV_ITEM
SET_FONT
Get font of an item
GET_FONT
Set Alignment of the Text in the Column You are able to set where the content of a column will be put: •
Left aligned
•
Centered
•
Right-aligned
You are able to change the alignment of text in the design object (header and footer area of page or
list) and in the ALV output. Alignment in the ALV Output You are able to set the alignment of the text for each column in the ALV output separately. Display type
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-sequential list
Yes Yes
Yes
ALV Tool
Tree structure Methods Function
Class
Method
Set alignment of the column
CL_SALV_COLUMN
SET_ALIGNMENT
Get alignment of the column
GET_ALIGNMENT
Alignment in the Design Object For the following elements, you are able to set the alignment in the design object: •
Header
•
Action information
•
Label
•
Text
The alignment is only applicable when the following applies: •
The text is in a table-type layout.
•
The column in which the text is located is wide enough.
You set the alignment for each text element individually. Display type
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-sequential list
Yes Yes
Yes
ALV Tool
Tree structure Methods Function
Class
Method
Set alignment in the design object
CL_SALV_FORM_ACTION_INFO CL_SALV_FORM_HEADER_INFO CL_SALV_FORM_LABEL CL_SALV_FORM_TEXT
SET_HORIZONTAL_ALIGNMENT
Get alignment in the design object
GET_HORIZONTAL_ALIGNMENT
Determine Lowercase and Uppercase If the texts in the internal data table use both uppercase and lowercase letters, you are able to choose whether they will be maintained in the ALV output or whether the lowercase letters should be converted to uppercase letters. Display type ALV Tool
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Hierarchical-sequential list
Yes
Tree structure
Yes
Yes
Yes
Yes
Methods Function
Class
Method
Convert lowercase letters to uppercase
CL_SALV_COLUMN
SET_LOWERCASE
Check whether lowercase letters are to be converted to uppercase letters
IS_LOWERCASE
Determine Display of Empty Cells You are able to determine whether empty cells are to contain a zero or a space. Display type
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-sequential list
Yes Yes
Yes
ALV Tool
Tree structure Methods Function
Class
Method
Determine display of empty cells
CL_SALV_COLUMN
SET_ZERO
Check how empty cells are to be displayed
IS_ZERO
Hiding Lines Between Columns and Rows Use You are able to separate the rows and columns from one another with lines, both in the ALV output and in the design object (header, footer area). Color and thickness of the lines are determined by the system. You cannot change them. Features You are able to make the following settings for lines: •
Hide lines between columns and rows
•
Display lines in the design object of the header and footer areas of a list or page
•
Display Lines Between Control Levels (Highlight Control Level Change section)
Displaying Lines in the ALV Output To display lines in the ALV output, you use one method for lines and one for columns. Display type ALV Tool Simple, two-dimensional table Hierarchical-sequential list
Classic ABAP list
Full screen
In the Container
Yes
Yes
Yes
Yes (only
horizontal) Tree structure
No
No
Methods Function
Class
Method
Display lines between rows
CL_SALV_DISPLAY_SETTINGS
SET_HORIZONTAL_LINES
Checks whether lines between the rows are being displayed
IS_HORIZONTAL_LINES
Display columns
SET_VERTICAL_LINES
lines
between
Checks whether lines between the columns are being displayed
IS_VERTICAL_LINES
Displaying Lines in the Design Object You are only able to display lines in table-type layouts within the design object. Here you use one method to determine whether you want to display vertical, horizontal, both or no lines. Display type
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-sequential list
Yes Yes
Yes
ALV Tool
Tree structure Methods Function Displaying Lines Design Object
in
the
Class
Method
CL_SALV_FORM_LAYOUT_GRID
SET_GRID_LINES
Changing the Display of Numeric Values Use You are able to determine how a numeric value from the internal data table is to be displayed in the ALV output. To do this, you can use the following properties: •
Number of decimal places
•
Unit of measurement
•
Currency
•
Rounding
With each of these properties, you either move the decimal point the desired number of places (thus changing the value of the number) or you change the number of decimal places after the
decimal point (the value of the number then stays the same). You are also able to combine two or more options. You are able to apply each of the properties in two ways: •
You assign the desired property with a specific value to the column that contains the values to be displayed. Each of the values in the column is changed and displayed in the same way.
•
You use a separate column that applies the desired property to individual rows of the ALV output. For more information, see Columns with Special Technical Significance, in the section called Control Columns That Are Assigned to a Column. Features
You are able to make the following settings for numeric columns: •
Setting properties such as number of decimal places, units of measure, currency and rounding
•
Displaying or hiding sign
•
Hide or display leading zeros
•
Determining Display of Empty Cells
The following is valid for all of these functions: Display type
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-sequential list
Yes Yes
Yes
ALV Tool
Tree structure
Determining Decimal Places, Units of Measure, Currency and Rounding You determine the number of decimal places, along with the unit of measure, currency and rounding for each column individually. Methods Function
Class
Method
Determine number of decimal places
CL_SALV_COLUMN
SET_DECIMALS
Get number of decimal places
GET_DECIMALS
Determine unit of measure
SET_CURRENCY
Get unit of measure
GET_CURRENCY
Determine currency
SET_QUANTITY
Get currency
GET_QUANTITY
Determine rounding
SET_ROUND
Get rounding
GET_ROUND
For columns with DDIC reference, the GET_DDIC_DECIMALS of class CL_SALV_COLUMN returns the number of decimal places that is set for the referenced data element. Displaying or Hiding sign By default, positive numbers are displayed without sign, and negative numbers are displayed with
sign. You are able to determine that the sign (-) not be displayed for negative numbers. Methods Function
Class
Method
Displaying or hiding sign
CL_SALV_COLUMN
SET_SIGN
Checks whether sign is being displayed or hidden
HAS_SIGN
Hiding or Displaying Leading Zeros For columns with data types n or NUMC (numeric text), the places that are in front of the value are filled with zeros (0). You are able to hide or display these zeros in front of a value. Display type
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-sequential list
Yes Yes
Yes
ALV Tool
Tree structure Methods Function Hiding Zeros
or
Displaying
Leading
Class
Method
CL_SALV_COLUMN
SET_LEADING_ZERO
Checks leading zeros are being displayed or hidden
HAS_LEADING_ZERO
Defining Column Width Use You are able to change the width of the columns in the ALV output in different ways. Here you differentiate between columns in the content of the ALV output (represented by a COLUMN object) and other types of columns (such as hierarchy column of the tree structure, column in design object). Features You are able to make the following settings for column width: •
Set output width of a column (COLUMN object)
•
Set width of hierarchy column in the tree structure
•
Change width of a column in table-type layout of a design object
•
Adapt width to space needed for the values
•
Hide column completely (section called Settings Visibility of a Column)
Set Output Width You are able to set the width of a column in the content of the ALV output no matter how large the field has been defined for the internal data table. Display type
Classic ABAP list
Full screen
In the Container
ALV Tool Simple, two-dimensional table
Yes
Hierarchical-sequential list
Yes
Tree structure
Yes
Yes
Yes
Yes
Methods Function
Class
Method
Set column width
CL_SALV_COLUMN
SET_OUTPUT_LENGTH
Get column width
GET_OUTPUT_LENGTH
Get column width of the referenced data element
GET_DDIC_OUTPUTLEN
Set Width of Hierarchy Column You are able to choose whether you want to specify the width of the hierarchy column in the tree structure in pixels or in characters. Display type
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
No
No
No
Hierarchical-sequential list
No Yes
Yes
ALV Tool
Tree structure Methods Function
Class
Method
Set whether the width of the hierarchy column is specified in characters or in pixels
CL_SALV_ TREE_SETTINGS
SET_HIERARCHY_SIZE_IN_PIXEL
Check whether the width of the hierarchy column is specified in characters or in pixels
IS_HIERARCHY_SIZE_IN_PIXEL
Set width of hierarchy column
SET_HIERARCHY_SIZE
Get width of hierarchy column
GET_HIERARCHY_SIZE
Width of a Column in Table-Type Layout of a Design Object If you use a table-type layout in a design object, you control the width of the column using its contents: the longer the text in a cell, the wider the column. Adapt Width to Space Required by Values You are able to automatically set the width of columns so that all values are displayed completely by optimizing the column. You can make this setting for each column individually or for all columns simultaneously. Display type
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-sequential list
Yes Yes
Yes
ALV Tool
Tree structure Methods
Function
Class
Method
Optimize individual column
CL_SALV_COLUMN
SET_OPTIMIZED
Check whether a column is optimized Optimize all columns simultaneously
IS_OPTIMIZED CL_SALV_COLUMNS
Check whether all columns are optimized
SET_OPTIMIZE IS_OPTIMIZED
In the printout, the columns that are output are exactly as wide as they are on the screen by default. In the full-screen display of a simple, two-dimensional table, you are able to determine that the column widths be optimized in the printout. To do this, use the method SET_COLUMN_OPTIMIZATION in the CL_SALV_PRINT class. With the IS_COLUMN_OPTIMIZATION you check whether the columns are optimized in the printout. 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
GET_DROPDOWNS
CL_SALV_DROPDOWNS
GET_HYPERLINKS
CL_SALV_HYPERLINKS
GET_TOOLTIPS
CL_SALV_TOOLTIPS
GET_FUNCTIONS
CL_SALV_FUNCTION
CL_SALV_FILTERS
GET_FILTER
CL_SALV_FILTER
CL_SALV_NODES
GET_NODE
CL_SALV_NODE
CL_SALV_SORTS
GET_SORTS
CL_SALV_SORT
CL_SALV_COLUMNS_HIERSEQ CL_SALV_COLUMNS_TREE CL_SALV _FUNCTIONAL_SETTINGS
CL_SALV_FUNCTIONS_LIST CL_SALV_FUNCTIONS_TREE
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.
Content of the ALV Output With the ALV object model, you display structured data in a specific way: in your choice of ALV tool, you determine the display type for the ALV output. In the application, you transfer a data table to the ALV object model. ALV then generates the required metadata from this table, that is the column description in the form of the individual COLUMN objects. The data table that ALV uses is a reference to the internal data table that your application transfers. This ensures that ALV always works with the correct data. If changes are made to the internal data table, you only need to let ALV know (with REFRESH) to complete the changes in the ALV output.
The data table or its reference has to exist over the entire life of the application. Due to the different data models upon which the three ALV tools are based, there are different requirements for the data tables that they transfer. In the following chapters you will learn how to •
Set the Internal Data Table
•
Proceed when the Structure or Content of the Internal Data Table Changes
Arranging a Data Record in Multiple Rows Use You are able to arrange the values of a data record in multiple rows. For example, you are able to ensure that all of the data is visible simultaneously even when there is a large number of columns.
If you spread a data record over multiple rows the ALV output is automatically displayed with stripes. Features For each individual column you determine in which row of a data record you wish to display your values. Display type
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
No
No
Hierarchical-sequential list
Yes No
No
ALV Tool
Tree structure Methods Function
Class
Method
Arranging values in multiple rows
CL_SALV_COLUMN
SET_ROW
Get rows in which the data is being displayed
GET_ROW
ALV Output Display in a Dialog Box Use You are able to display the ALV output in a separate dialog box, the ALV popup. Here you are able to use all functions of the currently applicable ALV tools as usual. Screen Status When
you
display
the
ALV
output
in
a
separate
dialog
box,
the
screen
status
SALV_TABLE_STDPOPUP (function group SALV_METADATA_STATUS) is automatically used.
If you
want to change this screen status, make a backup copy of the original screen status beforehand and then make your desired changes. Features You are able to make the following settings for the ALV popup: •
Display ALV output in a dialog box
•
Specify the size of the dialog box
The following is valid for all of these functions: Display type
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
No
Hierarchical-sequential list
Yes No
No
ALV Tool
Tree structure Display ALV Output in a Dialog Box
You display the ALV output in the dialog box by specifying the position of the dialog box on the screen. This is measured in columns and rows of characters: each character corresponds in width to one column, in height to one row. You specify the distance between the dialog box and the left side of the screen in columns and from the top of the work area in rows.
Methods Function
Class
Method
Display ALV output in a dialog box
CL_SALV_TABLE CL_SALV_HIERSEQ_TABLE
SET_SCREEN_POPUP (Parameter START_COLUMN bzw. START_LINE)
Get position of the dialog box
GET_SCREEN_POPUP
Specify the Size of the Dialog Box You specify the size of the dialog box only indirectly: •
The width of the dialog box is determined from the distance between the right side of the dialog box and the edge of the screen
•
The height of the dialog box is determined from the distance between the bottom of the dialog box and the upper edge of the work area.
Methods Function
Class
Method
Specify the Size of the Dialog Box
CL_SALV_TABLE CL_SALV_HIERSEQ_TABLE
SET_SCREEN_POPUP (Parameter END_COLUMN bzw. END_LINE)
Specify the size of the dialog box
GET_SCREEN_POPUP
Handling Events and Functions The ALV output cannot be edited, which means that users cannot make changes to the content of the ALV output themselves. The user can only change the display of the content, for example by sorting or filtering specific data records. However, you are able to enable and handle different types of interaction by the user that do not affect the content of the ALV output, but do trigger certain functions. •
You provide Pushbuttons or Menu Entries for generic ALV functions or define your own application-specific functions
•
In the columns of the ALV output, you provide elements for interaction such as pushbuttons, checkboxes or hyperlinks
•
You process the user’s clicks and double clicks on the ALV output.
•
You process specific key actions from the user
In every event handler method, you are able to change the content of the data table, for example. Then you need to refresh the display with the REFRESH method.
Make Functions Available Use By default, there are no functions available to users for working with the ALV output. Even the basic functions, such as sorting, filtering, printing and so on are not available with the simplest call of an ALV output. In order to allow the user to make use of a function, you have to expressly make it available. Functions are divided into two groups:
•
Generic ALV Functions
You are able to enables these functions independent of the objectives of your application. Generic ALV functions are sorting, filtering, managing layouts, printing, and so on. •
Custom Application-Specific Functions
You use your application to provide functions that are specially customized to the requirements of this application. In the ALV output, you make pushbuttons available with which users can trigger the function. Screen Status When you display a tree structure or a simple, two-dimensional table in a container, simply specify your desired functions with the appropriate setter method. In the following display types, on the other hand, ALV controls the entire screen: •
Simple, two-dimensional table in full screen
•
Hierarchical-sequential list
•
Tree structure in the full screen
Here you can decide which screen status will be used and also which functions will be offered to the user as menu entries and which ones will be offered as pushbuttons. In these display types, you are only able to display those functions that you have also entered into the screen status. Features Setting Screen Status You make the following settings with screen status in the full-screen display of the ALV output: •
Which generic ALV functions and which custom functions the user can use
•
Which functions are offered as pushbuttons and which are offered as a menu entry
•
In which order the pushbuttons or menu are displayed
By default, the following screen statuses will be used: •
For the simple, two-dimensional table and the hierarchical-sequential list of the screen status SALV_TABLE_STANDARD in the function group SALV_METADATA_STATUS
•
For the tree structure of the screen status STANDARD_TREE in the function group SLVC_FULLSCREEN
Do not change the original screen status. If you want to make changes to the screen status, for example because you want to make custom functions available, use the original screen status as a copy template and then change the copy as needed. You are able to set another screen status. Display type
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
No
Hierarchical-sequential list
Yes Yes
No
ALV Tool
Tree structure Methods Function
Class
Method
Set screen status
CL_SALV_TABLE
SET_SCREEN_STATUS
Get screen status
CL_SALV_HIERSEQ_TABLE
GET_SCREEN_STATUS
CL_SALV_TREE
Use of Generic ALV Functions Use You are able to provide functions so that users can work with the ALV output. The functions that the system provides for ALV are called generic ALV functions. Generic ALV functions include sorting, filtering, layouts settings and so on. Generic means that the system checks whether a function is useful for a specific situation. It enables or disables the pushbutton or menu entry accordingly. On the other hand, with self-defined functions, the system cannot influence the activation status.
The names of all generic ALV functions are listed as constants in the interfaces IF_SALV_C_FUNCTION LIST (for the simple, two-dimensional table and the hierarchical-sequential list) or IF_SALV_C_FUNCTION_TREE (for the tree structure). When Users Execute the Function When users select the pushbutton for a generic ALV function, they trigger two events (one after the other): •
BEFORE_SALV_FUNCTION The event takes place before the function is executed
•
AFTER_SALV_FUNCTION The event takes place after the function is finished
Both events originate in the classes CL_SALV_EVENTS_LIST or CL_SALV_EVENTS_TREE. If you register your application for these events, you are able to handle user actions and start a desired function. Arrangement of the Pushbuttons Depending on whether you use a generic function in an ALV output in a container or in a full-screen display, you proceed differently to set the position of a pushbutton or menu entry: •
In container display (simple, simple two-dimensional table or tree structure) you are not able to change the sequence of the pushbuttons.
•
In the other display types, you use the screen status to set the position of a pushbutton or the menu entry. The pushbutton is then displayed at the position set here no matter in which sequence you call the SET functions.
You are only able to set a function as a menu entry using the screen status. In the container display you are not able to influence the menu structure.
Function Groups You are able to enable or disable every generic ALV function. Most generic ALV functions however, are part of groups of functions that have been grouped together logically. In this way, you are able to enable all of the functions for this group with one command. Features You are able to make the following settings for generic ALV functions: •
Get function settings
•
Enable generic ALV functions
•
Check visibility and activation status of a self-defined function
The following is valid for all of these functions: Display type
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-Sequential List
Yes Yes
Yes
ALV Tool
Tree structure Get function settings
With every function that you activate, you generate an object of class CL_SALV_FUNCTION. You manage all of these objects using the list of all function objects: CL_SALV_FUNCTIONS_TREE (for the tree structure) or CL_SALV_FUNCTIONS_LIST (for the simple, two-dimensional table or the hierarchical-sequential list). The method GET_FUNCTIONS that returns the settings for all functions exists in each main ALV class. Using this object, you make all settings for the generic ALV functions. Methods Function
Class
Method
Get FUNCTIONS object
CL_SALV_TABLE
GET_FUNCTIONS
CL_SALV_HIERSEQ_TABLE CL_SALV_TREE Get all function objects
CL_SALV_FUNCTIONS_LIST
GET_FUNCTIONS
Check whether a function is a generic ALV function
CL_SALV_FUNCTIONS_TREE
IS_SALV_FUNCTION
Enable Generic ALV Functions For every generic ALV function, there is a setter method that you use to make the pushbutton or menu entry for the function visible and usable for the user. You have various options for displaying generic ALV functions: •
You enable each generic ALV function individually
•
You enable a function group. All of the functions for this function group are enabled simultaneously
•
You enable all generic ALV functions simultaneously
In the list-type ALV outputs (simple, two-dimensional table and hierarchical-sequential list), there is also a preset default selection of the most frequent generic ALV functions. Methods Function
Class
Method
Enable individual generic ALV functions
CL_SALV_FUNCTIONS_LIST
SET_
CL_SALV_FUNCTIONS_TREE
Enable function group
SET_GROUP_
Enable all generic ALV functions
SET_ALL
Enable preset default selection of generic ALV functions
CL_SALV_FUNCTIONS_LIST
SET_DEFAULT
Check Visibility and Activation Status of a Self-Defined Function With the setter methods (see above), you render a generic ALV function visible or hidden. In some cases, a generic ALV function can be visible, but temporarily not operable: the generic ALV function is disabled. Although you are able to change the activation status of self-defined functions, you do not have this option for generic ALV functions. Here the internal logic of ALV determines whether or not a function is operable.
You set the group Filter, making the functions SET_FILTER and SET_FILTER_DELETE visible. As long as you have not defined a filter, the function SET_FILTER_DELETE remains disabled. You are able to check the activation status of a self-defined function However, the associated method does not include the activation status that the system has set based on its internal logic.
When you try to change the activation status of a generic ALV function, you get an error. Methods Function
Class
Method
Check visibility
CL_SALV_FUNCTIONS_LIST
IS_VISIBLE
Check activation status
CL_SALV_FUNCTIONS_TREE
IS_ENABLED
Using Self-Defined, Application-Specific Functions Use You are able to provide functions that are specially customized to your application. To allow users to use these functions, you display pushbuttons – or, as long as you have access to the screen status – menu entries.
When Users Execute the Function If users select the pushbutton for a function that you have defined, they trigger the event ADDED_FUNCTION of classes CL_SALV_EVENTS_LIST or CL_SALV_EVENTS_TREE. If you register your application for this event, you get control in the method for the event handler and can start your desired function code. Arrangement of the Pushbuttons Depending on whether you use a self-defined function in an ALV output in a container or in a fullscreen display, you proceed differently to set the position of a pushbutton or menu entry: •
In the container display (simple, two-dimensional table or tree structure) you are able to choose whether you want to place the pushbuttons for self-defined functions to the right or the left of the pushbutton for the generic ALV functions: You also use the sequence in which you create the self-defined functions to set the sequence of the pushbuttons.
In the container display, you are only able to add pushbuttons in the application toolbar. You are not able to generate menu entries. •
In the other display types, you use the screen status to set the position of a pushbutton or the menu entry. The pushbutton is then displayed at the position set here no matter in which sequence you create the functions. Features
You are able to make the following settings for self-defined functions: •
Get function settings
•
Create and display self-defined functions
•
Check visibility and activation status of a self-defined function
•
Instead of a self-defined function, execute a generic ALV function Get Function Settings
With every function that you activate, you generate an object of class CL_SALV_FUNCTION. You manage all of these objects using the list of all function objects: CL_SALV_FUNCTIONS_TREE (for the tree structure) or CL_SALV_FUNCTIONS_LIST (for the simple, two-dimensional table or the hierarchical-sequential list). The method GET_FUNCTIONS that returns the settings for all functions exists in each main ALV class. Using this object, you make all settings for the self-defined functions. Display type
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-sequential list
Yes Yes
Yes
ALV Tool
Tree structure Methods Function
Class
Method
Get FUNCTIONS object
CL_SALV_TABLE
GET_FUNCTIONS
CL_SALV_HIERSEQ_TABLE CL_SALV_TREE Create, Display, and Delete Self-Defined Functions Depending on whether you use a self-defined function in an ALV output in a container or in a fullscreen display, you proceed differently to display the function: •
In the container display (simple, two-dimensional table or tree structure), you strictly create a function object with the desired properties and display the pushbutton.
•
In the other display types, you generate the function object indirectly by entering the self-defined function into the screen status. Here the function is display directly. You do not have to provide any other commands for the display.
In full-screen displays, you determine the appearance, tooltip and position for the function using the screen status, but in the container display, you make these settings when you are generating the function object. Display type
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
No
No
Yes
Hierarchical-sequential list
No No
Yes
ALV Tool
Tree structure Methods Function
Class
Method
Create and display a function object for a selfdefined function
CL_SALV_FUNCTIONS_LIST
ADD_FUNCTION
CL_SALV_FUNCTIONS_TREE
Delete function object
REMOVE_FUNCTION
Check whether a function object already exists
IS_ITEM
Set text for a pushbutton
ADD_FUNCTION (Parameter TEXT)
Set icon for a pushbutton
ADD_FUNCTION (Parameter ICON)
Set position within the application toolbar
ADD_FUNCTION (Parameter POSITION)
Set tooltip for the pushbutton
ADD_FUNCTION (Parameter TOOLTIP)
Check Visibility and Activation Status of a Self-Defined Function Sie können die Drucktasten bzw. Show and hide menu entries for self-defined functions. In addition you are also able to affect the operability of a self-defined function – in contrast to generic ALV functions: you enable or disable the function. For the visibility of self-defined functions, the following is valid: Display type ALV Tool Simple, two-dimensional table
Classic ABAP list
Full screen
In the Container
Yes
Yes
Yes
Hierarchical-sequential list
Yes
Tree structure
Yes
Yes
For the activation status of self-defined functions, the following is valid: Display type
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
No
No
Yes
Hierarchical-sequential list
No No
Yes
ALV Tool
Tree structure Methods Function
Class
Method
Show or hide a selfdefined function
CL_SALV_FUNCTIONS_LIST
SET_FUNCTION
CL_SALV_FUNCTIONS_TREE
Check visibility
IS_VISIBLE
Enable / disable a selfdefined function
ENABLE_FUNCTION
Check activation status
IS_ENABLED
Instead of a Self-Defined Function, Execute a Generic ALV Function Usually you want to execute the self-defined function for which you have defined a pushbutton or menu entry upon user action. However, in specific cases, if you wish to execute a function other that the one originally set, you are able to specify the desired (alternative) generic ALV function in the event handler routine of the event ADDED_FUNCTION. Display type
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
No
No
Yes
Hierarchical-sequential list
No No
Yes
ALV Tool
Tree structure Methods Function
Class
Method
Instead of a self-defined function, execute a generic ALV function
CL_SALV_TABLE CL_SALV_TREE
SET_FUNCTION
Interactive Element Display Use In the content of your ALV output, you are able to display various elements in place of text. Some of these elements can be treated as a click area for the user. You are able to display the following elements:
•
Checkbox
In list-type ALV ouputs, the checkbox is disabled. With the content of the column, you are only to display whether the checkbox is set or not. In the tree structure, however, you are able to handle users actions on this element using an event. •
Pushbutton
You are able to handle user actions on this element with an event. •
Hyperlink
You specify the Internet addresses (URLs). Users can then call up the corresponding page in the Internet browser by clicking on one of these Internet addresses. •
Click Area
You are able to handle user actions on this element with an event.
In list-type ALV outputs, the setting for interactive elements is called cell type. In tree structures it is called type of item. Features You are able to make the following settings for interactive elements: •
Get current setting
•
Assign cell type or type of item Get Current Setting
In list-type ALV outputs, you are able to assign the cell type in two ways: •
All cells of a column get the same cell type. Here the cell type is thus a property of the column.
•
Using a column for cell types, you assign any cell type to each of the individual rows.
In the tree structures, on the other hand, the type is a property of the item. Depending on of what the cell / item type is a property, you proceed differently to obtain the current settings. Methods Function
Class
Method
Get the property of a column
CL_SALV_TABLE
GET_COLUMNS
Check whether a column exists for cell types
CL_SALV_COLUMNS_LIST
GET_CELL_TYPE_COLUMN
Get the cell type of a column
CL_SALV_COLUMN_LIST
GET_CELL_TYPE
Get properties of an item
CL_SALV_TREE
GET_NODES
CL_SALV_NODES
GET_NODE
CL_SALV_NODE
GET_ITEM GET_HIERARCHY_ITEM
CL_SALV_ITEM
GET_TYPE
Assign Cell Type or Type of Item If all prerequisites are fulfilled for displaying an interactive element in a cell or item, you are able to
assign the type to the cell or item. See the prerequisites for each of the individual elements below. Methods Function
Class
Method
Display element in a cell
CL_SALV_COLUMN_LIST
SET_CELL_TYPE
Display element in an item
CL_SALV_ITEM
SET_TYPE
Checkbox Display Use A checkbox displays two statuses: the indicator is set (a checkbox is displayed in the field) or it is not set (the field is empty). Both statuses can be overwritten by the activation: if a checkbox is enabled (the field is white), the user can change the status of the checkbox by clicking on it. If the checkbox is disabled (the field is gray) a click does not change anything. You are able to display your ALV output in cells or items.
In the class ABAP list and the hierarchical-sequential list, you are able to use display type to determine that a checkbox be displayed in front of every row for the user to select the row. You are able to display checkboxes in all ALV tools. In the classic ABAP list and the hierarchicalsequential list, however, you are not able to activate the checkboxes, which means the user is not able to change the value of a checkbox. If the User Changes the Value You are able to enable checkboxes, which means you allow the user to change the value of the checkbox. Then you are able to handle the following events with your application: •
In the simple, two-dimensional table, the user triggers the event LINK_CLICK from class CL_SALV_EVENTS_TABLE by changing the checkbox.
•
In the tree structure, the user triggers the event CHECKBOX_CHANGE from class CL_SALV_EVENTS_TREE Data Type, Cell Type and Value
The cells or items in which you wish to display the checkbox must have an alphanumeric data type. Depending on whether you are using checkboxes in list-type ALV outputs or in the tree structure, you proceed differently when setting the value of the checkbox: •
•
In the tree structure, you set two properties of individual items:
Checkbox can be changed/cannot be changed
Indicator is set/not set
In the other ALV tools, you control the display of the checkbox using the combination of cell type and value of the cell:
The CHECKBOX cell type always displays a disabled checkbox. The cell type
CHECKBOX_HOTSPOT shows an enabled checkbox
For the values ’1’ or ’X’, the indicator for the checkbox is set. For the values ’0’
or ’ ’ , the indicator is not set. The following table shows which value a cell or an item needs to include so that the checkbox is displayed as you want it to be: Value of a Checkbox Checkbox
Description
Cell Type
Value of the Cell
Checkbox enabled Indicator not set
CHECKBOX_ HOTSPOT
’0’ or ’ ’
Checkbox enabled Indicator set
CHECKBOX_ HOTSPOT
’1’ or ’X’
Checkbox disabled Indicator not set
CHECKBOX
’0’ or ’ ’
Checkbox disabled Indicator set
CHECKBOX
’1’ or ’X’
Checkbox hidden
CHECKBOX
’-’
CHECKBOX_ HOTSPOT Features You are able to make the following settings for checkboxes: •
Display checkbox (assign cell and item type)
•
Enable/disable checkbox in the item
•
Set/remove indicator for the checkbox in the item Checkbox Display
•
To display a disabled checkbox in a list-type ALV output, use the cell type CHECKBOX.
•
To display an enabled checkbox in the simple, two-dimensional table (full screen or container), use the cell type CHECKBOX_HOTSPOT.
•
To display a checkbox in a tree structure, use the type of item CHECKBOX Enable/Disable Checkbox in the Item
In order for the user to be able to change the value of a checkbox in the tree structure, you have to enable it. Display type
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
No
No
No
Hierarchical-sequential list
No Yes
Yes
ALV Tool
Tree structure Methods Function
Class
Method
Enable checkbox
CL_SALV_ITEM
SET_EDITABLE
Prüfen, ob Ankreuzfeld aktiviert ist
IS_EDITABLE
Enable/Disable the Checkbox in the Cell In list-type ALV outputs, you enable or disable a checkbox using the cell type: •
To display a disabled checkbox in a list-type ALV output, use the cell type CHECKBOX.
•
To display an enabled checkbox in the simple, two-dimensional table (full screen or container), use the cell type CHECKBOX_HOTSPOT.
Set/Remove Indicator for the Checkbox in the Item You are able to change the value of a checkbox in the tree structure using your application. Display type
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
No
No
No
Hierarchical-sequential list
No Yes
Yes
ALV Tool
Tree structure Methods Function
Class
Method
Set the indicator for the checkbox
CL_SALV_ITEM
SET_CHECKED
Check whether the indicator for the checkbox is set
IS_CHECKED
Set/Remove Indicator for the Checkbox in the Cell In list-type ALV outputs, you can only control whether the indicator of a checkbox is set or not with the value of the cell. In enabled checkboxes (cell type CHECKBOX_HOTSPOT), you are able to use the event LINK_CLICK to adapt the value of the cell when the user clicks on the checkbox. Checkbox Display Use A checkbox displays two statuses: the indicator is set (a checkbox is displayed in the field) or it is not set (the field is empty). Both statuses can be overwritten by the activation: if a checkbox is enabled (the field is white), the user can change the status of the checkbox by clicking on it. If the checkbox is disabled (the field is gray) a click does not change anything. You are able to display your ALV output in cells or items.
In the class ABAP list and the hierarchical-sequential list, you are able to use display type to determine that a checkbox be displayed in front of every row for the user to select the row. You are able to display checkboxes in all ALV tools. In the classic ABAP list and the hierarchicalsequential list, however, you are not able to activate the checkboxes, which means the user is not able to change the value of a checkbox. If the User Changes the Value You are able to enable checkboxes, which means you allow the user to change the value of the checkbox. Then you are able to handle the following events with your application:
•
In the simple, two-dimensional table, the user triggers the event LINK_CLICK from class CL_SALV_EVENTS_TABLE by changing the checkbox.
•
In the tree structure, the user triggers the event CHECKBOX_CHANGE from class CL_SALV_EVENTS_TREE Data Type, Cell Type and Value
The cells or items in which you wish to display the checkbox must have an alphanumeric data type. Depending on whether you are using checkboxes in list-type ALV outputs or in the tree structure, you proceed differently when setting the value of the checkbox: •
•
In the tree structure, you set two properties of individual items:
Checkbox can be changed/cannot be changed
Indicator is set/not set
In the other ALV tools, you control the display of the checkbox using the combination of cell type and value of the cell:
The CHECKBOX cell type always displays a disabled checkbox. The cell type
CHECKBOX_HOTSPOT shows an enabled checkbox
For the values ’1’ or ’X’, the indicator for the checkbox is set. For the values ’0’
or ’ ’ , the indicator is not set. The following table shows which value a cell or an item needs to include so that the checkbox is displayed as you want it to be: Value of a Checkbox Checkbox
Description
Cell Type
Value of the Cell
Checkbox enabled Indicator not set
CHECKBOX_ HOTSPOT
’0’ or ’ ’
Checkbox enabled Indicator set
CHECKBOX_ HOTSPOT
’1’ or ’X’
Checkbox disabled Indicator not set
CHECKBOX
’0’ or ’ ’
Checkbox disabled Indicator set
CHECKBOX
’1’ or ’X’
Checkbox hidden
CHECKBOX
’-’
CHECKBOX_ HOTSPOT Features You are able to make the following settings for checkboxes: •
Display checkbox (assign cell and item type)
•
Enable/disable checkbox in the item
•
Set/remove indicator for the checkbox in the item Checkbox Display
•
To display a disabled checkbox in a list-type ALV output, use the cell type CHECKBOX.
•
To display an enabled checkbox in the simple, two-dimensional table (full screen or container), use the cell type CHECKBOX_HOTSPOT.
•
To display a checkbox in a tree structure, use the type of item CHECKBOX Enable/Disable Checkbox in the Item
In order for the user to be able to change the value of a checkbox in the tree structure, you have to enable it. Display type
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
No
No
No
Hierarchical-sequential list
No Yes
Yes
ALV Tool
Tree structure Methods Function
Class
Method
Enable checkbox
CL_SALV_ITEM
SET_EDITABLE
Prüfen, ob Ankreuzfeld aktiviert ist
IS_EDITABLE
Enable/Disable the Checkbox in the Cell In list-type ALV outputs, you enable or disable a checkbox using the cell type: •
To display a disabled checkbox in a list-type ALV output, use the cell type CHECKBOX.
•
To display an enabled checkbox in the simple, two-dimensional table (full screen or container), use the cell type CHECKBOX_HOTSPOT.
Set/Remove Indicator for the Checkbox in the Item You are able to change the value of a checkbox in the tree structure using your application. Display type
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
No
No
No
Hierarchical-sequential list
No Yes
Yes
ALV Tool
Tree structure Methods Function
Class
Method
Set the indicator for the checkbox
CL_SALV_ITEM
SET_CHECKED
Check whether the indicator for the checkbox is set
IS_CHECKED
Set/Remove Indicator for the Checkbox in the Cell In list-type ALV outputs, you can only control whether the indicator of a checkbox is set or not with the value of the cell. In enabled checkboxes (cell type CHECKBOX_HOTSPOT), you are able to use the event LINK_CLICK to adapt the value of the cell when the user clicks on the checkbox.
Internet Address Display Use You are able to manage any number of Internet addresses as hyperlink objects. Each of these hyperlink objects is identified by a unique key. You are able to display any one hyperlink object in any cell. To do this, use the hyperlink column (see Columns with Special Technical Meaning, section Control Columns That Contain Information for Any Number of Columns). The contents of the hyperlink column then show the affected cell. The affected cell then includes the key for the hyperlink object.
Columns that contain the key for the hyperlink object have data type INT4. You can also determine that the Internet address that is displayed in the cell has been enabled as a click area. This means, when the user clicks on the Internet address, an Internet browser starts, which takes the user to the specified Internet page. To enable an Internet Address as a Click Area use the cell type. These are valid for the functions of Internet addresses: Display type
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-sequential list
Yes No
No
ALV Tool
Tree structure Features
You are able to make the following settings for Internet addresses: •
Get hyperlink objects
•
Create, change and delete hyperlink objects
•
Display Internet Address
•
Define Internet address as click area (assign cell type) Get Hyperlink Objects
In every main ALV class in which display of hyperlink objects is possible, there is a method GET_FUNCTIONAL_SETTINGS, which returns, among other things, the hyperlink objects of the ALV output (class CL_SALV_HYPERLINKS). Using this object you obtain the desired hyperlink object with the methods GET or GET_HYPERLINK. Methods Function
Class
Method
Get hyperlinks
CL_SALV_TABLE
GET_FUNCTIONAL_ SETTINGS
CL_SALV_HIERSEQ_TABLE Get all hyperlink objects
CL_SALV_FUNCTIONAL_SETTINGS
GET_HYPERLINKS
CL_SALV_HYPERLINKS
GET
Get a specific hyperlink object
CL_SALV_HYPERLINKS
GET_HYPERLINK
Get Internet
CL_SALV_HYPERLINK
GET_HYPERLINK
address Get key
GET_HANDLE Create, Change and Delete Hyperlink Objects
You are able to create any number of hyperlink objects. A hyperlink object includes two components: the Internet address and a key that you can use later to address the hyperlink object. You are able to delete hyperlink objects either individually or all at once. Methods Function
Class
Method
Create hyperlink object
CL_SALV_HYPERLINKS
ADD_HYPERLINK
Delete individual hyperlink object
REMOVE_HYPERLINK
Delete all hyperlink objects
CLEAR
Change hyperlink object (address)
CL_SALV_HYPERLINK
SET_HYPERLINK
Define Internet Address as Click Area To define the Internet address in a cell as a click area, that is, to display it underlined, use the Cell Type LINK.
Click Area Display Use You are able to define the content of a cell as a click area. When users click on this content, they trigger an event that you can handle as needed.
You are able to display icons in a column. If you later define the cells with the icons as click areas, the user then triggers the event by clicking on the icon. These are valid for the functions of click areas: Display type
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-sequential list
Yes Yes
Yes
ALV Tool
Tree structure
If users select a click area, they trigger the LINK_CLICK event (class CL_SALV_EVENTS_TABLE or CL_SALV_EVENTS_HIERSEQ or CL_SALV_EVENTS_TREE)
...
Features You are able to make the following settings for click areas: •
Display click area (assign cell and item type)
Click Area Display •
To define a cell as a click area in a list-type ALV output, use the cell type HOTSPOT
•
To define an item in a tree structure as a click area, use the type of item LINK.
Handling Single and Double Clicks Use Usually the user selects areas in the ALV output, by clicking - and perhaps also pressing CTRL or shift - in the ALV output. You are also able to determine which functions will be started when the user performs the following mouse actions: •
Single click on a cell or an item of the ALV output
•
Double click on a cell or an item of the ALV output or alternatively Selecting a cell or an item of the ALV output and pressing F2
For more information on clicking options, see Displaying Interactive Elements Features You are able to make the following settings for mouse actions: •
Functions for single click
•
Functions for Double Click or F2
The following is valid for all of these functions: Display type
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-sequential list
Yes Yes
Yes
ALV Tool
Tree structure Functions for Single Click
So that the user not only selects the rows or the item with a single click, but also triggers a specific function, you have to ensure the following: •
•
The cells/items for which these functions are to be triggered have a specific Cell or Item Type:
In list-like ALV outputs, the cells have the cell type HOTSPOT
In tree structures the items have the item type LINK
You have registered your application for the event LINK_CLICK (class CL_SALV_EVENTS_TABLE, CL_SALV_EVENTS_HIERSEQ or CL_SALV_EVENTS_TREE) and programmed it into a suitable event handler.
Functions for Double Click or F2 You have two options for processing the double click or F2 being pressed: •
You register your application for the event DOUBLE_CLICK (class CL_SALV_EVENTS_TABLE, CL_SALV_EVENTS_HIERSEQ or CL_SALV_EVENTS_TREE) or
•
You specify the function code of the function directly that is to be executed with a double click or F2.
The DOUBLE_CLICK event returns the position (cell or item) where the user double clicked. The second option, on the other hand, does not return information about exactly where the double click occurred. Methods Function
Class
Method
Set function code
CL_SALV_FUNCTIONAL_SETTINGS
SET_F2_CODE
Get function code
GET_F2_CODE
Handling Keyboard Actions Use Some keys on the keyboard have special meaning in ALV and you can assign specific functions to others: •
F1 Function Key
The user calls a help text for the selected column using the F1 function key. •
F2 Function Key
This key is always an alternative to double clicking. You determine which function is triggered when the user double clicks or presses F2. You cannot change its meaning. •
F4 function key With the F4 function key, users call a value list with possible entries that are possible and useful for their current situation. Features
You are able to make the following settings for key settings: •
Using an F1 Help Text for Another Data Element
•
Assigning any functions to keys Assigning Any Functions to Keys
In the tree structure, you are able to specify functions for a selection of keys and key combinations that are to be executed when the user presses these buttons. Display type ALV Tool Simple, two-dimensional table
Classic ABAP list
Full screen
In the Container
No
No
No
Hierarchical-sequential list
No
Tree structure
Yes
Yes
You proceed in two steps: •
You specify which of the possible keys trigger the event KEYPRESS of class CL_SALV_EVENTS_TREE. You repeat this specification for every key that you wish to register for the event.
•
You specify which function will be executed when the user presses the appropriate key. To do this, register the application for the event and program the desired event handler.
You can assign the following keys and key combinations in the tree structure with the desired functions: •
F1 function key
•
F4 function key
•
Remove
•
Enter key
•
Insert
•
Control plus X
•
Control plus C
•
Control plus V
By default, each key listed here is used for very specific purposes (for example, with the F4 function key, the user calls a dialog box with a value list of the permitted or useful entries for the current column). Find out about the conventions in your company as to the meaning of the individual keys. SAP recommends that you do not change the original objectives of the keys. Methods Function
Class
Method
Register the key for an event
CL_SALV_EVENTS_TREE
ADD_KEY_FOR_KEYPRESS
Delete entire list of keys that trigger the event
REMOVE_ALL_KEYS_ FOR_KEYPRESS
Providing Help for Users You are able to provide several types of help for users who are working with ALV: •
F1 Help
For each column, you specify a DDIC element that includes a suitable F1 help text. If the user selects a column and presses the F1 function key, the help text appears.
•
ToolTips
You are able to define tooltips for various elements of the ALV output. If the user moves the mouse pointer over the element and rests it there for a moment, the text box with the tooltip text appears.
In the tree structure you are able to handle events for various keys and to define any functions for them in this way. The function keys F1 and F4 are also available here. SAP recommends that you only use these keys for the help functions.
Provide Tooltips Use Tooltips allow you to define short help texts for various elements of the ALV output: •
By default the texts for tooltips are displayed for users when they move the mouse pointer over the column header and rest it there for a moment.
•
For physically impaired users, especially blind or visually impaired ones, the tooltip texts are read aloud using screen reader technology.
You are able to define tooltips for the following elements of your ALV output: •
For column headers
•
For functions in the application toolbar
•
For colors, exceptions and symbols
•
For elements in the design object
Depending on the element for which you want to define a tooltip, you proceed differently. Features You are able to make the following settings for tooltips: •
Tooltip Object Management and Generation for Colors, Exceptions and Symbols
•
Generation of Tooltips for Column Headers
•
Generation of Tooltips for Functions
•
Generation of Tooltips for Icons and Symbols
•
Generation of Tooltips for Elements in the Design Object
Tooltip Object Generation and Management Use You are able to assign the tooltip objects to the following elements: •
Symbols
•
Exceptions
•
Colors of cells
You use tooltip objects when the element to which the tooltip belongs can appear multiple times: to ensure that the same tooltip text is displayed every time, when an element is displayed assign a specific tooltip object to the element.
The color green always means Released. In order to always display exactly this text as tool tip when a row is green, assign the appropriate tooltip to the color. The tooltip object contains the following information: •
The type of tooltip object (that is for which element the tooltip can be sued)
•
The indicator for the element
•
The text that is displayed as tooltip Features
You are able to make the following settings for tooltip objects: •
Get tooltip object
•
Create, change and delete tooltip object
The following is valid for all of these functions: Display type
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-sequential list
Yes Yes
Yes
ALV Tool
Tree structure Get Tooltip Object
In every main ALV class there is a method that returns all tool tip objects of the ALV output (class CL_SALV_TOOLTIPS). Using this object you obtain the desired tooltip object with the methods GET or GET_TOOLTIP. Methods Function
Class
Method
Get tooltips
CL_SALV_TABLE
GET_FUNCTIONAL_ SETTINGS
CL_SALV_HIERSEQ_TABLE
Get all tooltip objects
Get specific tooltip object
CL_SALV_TREE
GET_TREE_SETTINGS
CL_SALV_FUNCTIONAL_SETTINGS
GET_TOOLTIPS
CL_SALV_TREE_SETTINGS CL_SALV_TOOLTIPS
GET
CL_SALV_TOOLTIPS
GET_TOOLTIP
Create, Change and Delete Tooltip Object You are able to create any number of tooltip objects. You are able to delete tooltip objects either individually or all at once. Methods
Function Get tooltip object
Class CL_SALV_TOOLTIPS
Method ADD_TOOLTIP
Delete individual tooltip object
REMOVE_TOOLTIP
Delete all tooltip objects
CLEAR
Change the text for the tooltip object
CL_SALV_TOOLTIP
SET_TOOLTIP
Get the text for the tooltip object
GET_TOOLTIP
Get type of tooltip
GET_TYPE
Get indicator for element
GET_VALUE
Generation of ToolTips for Icons and Symbols Use You are able to display icons in the ALV output. To do this, you use a special indicator that uniquely identify the graphic file in your system. You are able to define a tooltip for each icon individually. To do this, you add a separator and the text of the tooltip to the indicator. The following graphic shows the structure of the indicator with a tooltip:
The indicator @DL\QToolTip for Icon ABC@ shows the following tooltip:
For symbols, proceed in the same way.
F1 Help Provision Use You are able to store a help text for each element in the Data Dictionary (DDIC) – independent of ALV. Wherever this DDIC element is used, the user is able to call up this help text with the F1 function key.
In the tree structure, you are able to specify any function for the F1 function key. We strongly recommend that you use F1 help here. You are able to specify a “foreign” DDIC element to a column without DDIC reference and then to use the F1 help text from it for your column. Features You are able to make the following settings for F1 help: •
Use an F1 help text from another DDIC element Using an F1 Help Text from Another DDIC Element Display type
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-sequential list
Yes Yes
Yes
ALV Tool
Tree structure Methods Function
Class
Method
Use an F1 help text from another DDIC element
CL_SALV_COLUMN
SET_F1_ROLLNAME
Get name of the DDIC element from which the F1 help text has been taken
GET_F1_ROLLNAME
Making Settings for Printing Use Users can print the ALV output on a printer or they can view the printout on the screen. You are able to change the look of these printouts by making various settings in the list-type ALV outputs using the ALV object model. For all of the following functions, this is valid: Display type
Classic ABAP list
Full screen
In the Container
Simple, two-dimensional table
Yes
Yes
Yes
Hierarchical-sequential list
Yes No
No
ALV Tool
Tree structure
Of course the user is also able to print a tree structure. However, you cannot make settings for the printout here with the ALV object model. No matter which display type you use to display the ALV output on the screen: in the printout, the ALV output is converted to the classic ABAP list (or to a list in the style of the ABAP list) and is
printed in this form. Features You can make the following settings for the printout of the ALV output: •
Output additional information
•
Output standard title of the program
•
Determine that the ALV be called in print mode
•
Take actual list size into consideration during printing
•
Optimize Column Width in the Printout
•
Reserve Rows for Event END_OF_PAGE
Output Additional Information In addition to the actual ALV output you are able to output two areas in the printout: •
List information Information as to which filter and which sort are being applied to the ALV output and as to how many data records the ALV output is restricted.
•
Selection information Information as to which application-specific selection criteria the user used to call the ALV output (for example company code or material number)
If you activate one or both pieces of additional information, the corresponding information blocks are printed before the ALV output. You are able to determine whether a page break should be inserted after these information blocks, thus causing the additional information to appear on a separate page as a cover sheet, or whether the ALV output should be added directly after the additional information. Methods Function
Class
Method
Output of list information
CL_SALV_PRINT
SET_LISTINFO_ON
Check whether list information are being output
IS_LISTINFO_ON
Output selection information
SET_SELECTIONINFO_ON
Check whether selection information is being output
IS_SELECTIONINFO_ON
Output additional information on a separate page
SET_COVERPAGE_ON
Check whether additional information is being printed on a separate page
IS_COVERPAGE_ON
Output Standard Title of the Program The standard title of the program comprises the current date, the title of the ALV output and the page number. You are able to show the standard title. Methods Function
Class
Method
Output standard title of the
CL_SALV_PRINT
SET_REPORT_
program
STANDARD_HEADER_ON Determine that the ALV Be Called in Print Mode
You are able to print the ALV output directly without having to first display it on the screen. Methods Function
Class
Method
Print ALV output directly
CL_SALV_PRINT
SET_PRINT_ONLY
Check whether ALV output is being printed directly
IS_PRINT_ONLY
Take Actual List Size into Consideration During Printing You can use the application to determine how wide the list should be in the printout. If the width of the ALV output has changed (for example because the user is showing columns), it can be that the page is not big enough to show all the information. You are able to set that ALV determine the current size before printing and then changes the print parameters accordingly. Methods Function
Class
Method
Take actual list size into consideration during printing
CL_SALV_PRINT
SET_PRINT_PARAMETERS_ ENABLED
Check whether the list size can be adapted
IS_PRINT_PARAMETERS_ ENABLED