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:

  1. We get access to the 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.
    How to do it...
  2. Next, we define the class 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.
    How to do it...
  3. 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 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.
    How to do it...
  4. Finally, the 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.
    How to do it...

    The previous code will make sure that the on_click_hotspot method is called when the user clicks a particular cell of PERNR.

How it works...

The Pers.No column is displayed as underlined and selectable through a hotspot, as shown in the following screenshot:

How it works...

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.

How it works...

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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.227.134.133