Adding Hotspot to columns
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.
How to do it...
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:
- We get access to the
PERNR
column and call theset_cell_type
method for it. Then, we pass thehotspot
static constant attribute of theif_salv_c_cell_type
interface to it. - Next, we define the class
myhotspot
. Within the class definition, we create a static public methodon_click_hotspot
that will be called when a hotspot cell is clicked. This imports the row and column pertaining to the selection. - Within the implementation of this class, we read the row from the table
IT_PA0008
that the user has selected. The necessary details are read from tablePA0008
using aSELECT
statement. The function moduleHR_INFOTYPE_OPERATION
is then called in order to display the details of the employeeInfotype 0008
record in display mode of transactionPA20
. - Finally, the
SET HANDLER
statement is called in order to link the static methodon_click_hotspot
of the classmyhotspot
to the ALV. Before that, we get the handle to theevents
object of the ALV using theget_event
method.The previous code will make sure that the
on_click_hotspot
method is called when the user clicks a particular cell ofPERNR
.
How it works...
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.
See also
- http://help-abap.zevolving.com/2008/09/salv-table-8-add-handle-hotspot/
- http://www.sapfans.com/forums/viewtopic.php?f=13&t=158570
- Standard SAP demo programs
SALV_DEMO_TABLE_EVENTS and SALV_DEMO_TABLE_SIMPLE