Author: Thomas Jung
Submitted: April 12, 2007
I've had quite the week for Web Dynpro ABAP ALV questions. The most recent question regarded fixing a column. This comes into play when you have a smaller number of columns displayed than the total number of columns in a ALV table. Like in Excel, it would be nice to be able to freeze one or more columns and always have them displayed even as the user must scroll through the display of the additional columns.
We are going to take the example that started with needing to control the events around the standard buttons and was later enhanced to include multiple ALV components as the starting point. We will extend the example so that the ALV displaying the SFLIGHT data will only show 5 columns at a time and the Carrier ID column will remain fixed.
This solution is easier than the first two. We need only to add some coding to the DOINIT method of the component controller after the ALV Component Usage initialization.
First we will use the SET_SCROLLABLE_COL_COUNT method to set the displayed number of columns. Any fixed columns are not counted so if we want 5 columns displayed total and one of them will always be fixed, we need to set the value to 4.
Now we need to get access to the column object for the Carrier ID column. This object, CL_SALV_WD_COLUMN, has the method SET_FIXED_POSITION that we need. It is possible to fix columns to either the right or left side of the ALV table display.
If you were going to fix more than one column, then you might want to consider calling GET_COLUMNS instead of GET_COLUMN. This will alternative method will return an internal table filled with object references for each column in the ALV table - allowing for easier processing of multiple columns.
The following images show how the Carrier ID column stays in the first position and visible even as the user scrolls through the additional columns that are available.
If you would like to import the entire Web Dynpro Component of this example; the following is a link to a SAPlink SLNK file that contains the project. You will need at least the 1.3 version of SAPlink and the Web Dynpro Component plug-in to import the SLNK.