Adaptation of ALV Object Model Properties
As already described, when working with the ALV object model, you must, first, generate an instance of the class CL_SALV_TABLE, and this object represents the ALV as a whole.
However, the ALV has properties and subobjects (for example columns, buttons, layouts, print settings, and so on), which, as a programmer, you may want to manipulate or change.
Each of the ALV properties or subobjects is itself represented by another ABAP class. (These classes do not inherit from CL_SALV_TABLE, but the classes are, of course, related).
The main class of the ALV Object Model is the class CL_SALV_TABLE. For the other related classes, naming conventions were used by SAP to help you to determine which class relates to which property or group of properties.
All of the class names start CL_SALV_*. If the name is plural (for example, CL_SALV_COLUMNS_TABLE), it refers to the properties of a group of ALV Elements (in this example, all columns). If the name is singular (such as CL_SALV_COLUMN_TABLE), it relates to the properties of a single element (in this example, a single column).
Other Classes Belonging to the ALV Object Model
General Principle when Changing ALV Properties
The class CL_SALV_TABLE has GET methods for each property, which you can use to fetch the appropriate object. The object that represents each properly of the ALV is, therefore, not created with a CREATE OBJECT statement, but is, instead, returned by the appropriate GET_XXXX method call.
Each class belonging to the ALV object Model provides methods suitable for the object that you are dealing with. These methods can be called for the object fetched in step 1.
GET Methods
Get method |
Return object of type |
GET_COLUMNS |
CL_SALV_COLUMNS_TABLE |
GET_FUNCTIONS |
CL_SALV_FUNCTIONS_LIST |
GET_FUNCTIONAL_SETTINGS |
CL_SALV_FUNCTIONAL_SETTING |
GET_DISPLAY_SETTING |
CL_SALV_DISPLAY_SETTINGS |
GET_EVENT |
CL_SALV_EVENTS_TABLE |
GET_LAYOUT |
CL_SALV_LAYOUT |
GET_PRINT |
CL_SALV_PRINT |
GET_SELECTIONS |
CL_SALV_SELECTIONS |
GET_AGGREGATIONS |
CL_SALV_AGGREGATIONS |
GET_SORTS |
CL_SALV_SORTS |
GET_FILTES |
CL_SALV_FILTERS |
GET Methods of the Other CL_SALV_XXXXX Classes
Example- Column Properties
In the example in the figure, first the object that represents all columns is fetched. Then two method calls are performed for the object, one to optimize the width of all columns, and the second to assign a column position to a specific column (in this case, DISTANCE). (Although it may seem that this is a method that relates to one specific column, of course changing the column position of one column affects the column position of all columns; this is why this method is called for the object which represents all columns).
From this example, the following rules can be seen: