It may also be required to display hotspots (similar to hyperlinks) for an entire column in the ALV display. Clicking a particular hotspot cell will take the user to another detail screen. In this recipe, we will add hotspot functionality to the PERNR
column.
We will see how a particular column may be made to appear as a hotspot. We will also add the necessary code that is needed to carry out the steps needed for the hotspot selection. Proceed as follows:
PERNR
column and call the set_cell_type
method for it. Then, we pass the hotspot
static constant attribute of the if_salv_c_cell_type
interface to it.myhotspot
. Within the class definition, we create a static public method on_click_hotspot
that will be called when a hotspot cell is clicked. This imports the row and column pertaining to the selection.IT_PA0008
that the user has selected. The necessary details are read from table PA0008
using a SELECT
statement. The function module HR_INFOTYPE_OPERATION
is then called in order to display the details of the employee Infotype 0008
record in display mode of transaction PA20
.SET HANDLER
statement is called in order to link the static method on_click_hotspot
of the class myhotspot
to the ALV. Before that, we get the handle to the events
object of the ALV using the get_event
method.The previous code will make sure that the on_click_hotspot
method is called when the user clicks a particular cell of PERNR
.
The Pers.No column is displayed as underlined and selectable through a hotspot, as shown in the following screenshot:
When the user clicks a particular row displayed as a hotspot within the PERNR
column, the method on_click_hotspot
is triggered. Within the method, the importing parameters row
and column
contain the number of the selected row and the column name (PERNR
) respectively.
The code written within the on_click_hotspot
method is then executed. The corresponding record is read from the table IT_PA0008
using the READ
statement. The SELECT
statement is used for reading additional information related to the employee selected. This information is then passed on to the function module HR_INFOTYPE_OPERATION
with other Displays
parameters in order to display the record in transaction PA20
(Display Master Data) transaction.
SALV_DEMO_TABLE_EVENTS and SALV_DEMO_TABLE_SIMPLE
18.227.134.133