官术网_书友最值得收藏!

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.

See also

主站蜘蛛池模板: 漳浦县| 江永县| 甘德县| 南陵县| 临沂市| 宝应县| 安康市| 肇庆市| 恩施市| 晋江市| 黄浦区| 时尚| 奎屯市| 江陵县| 惠州市| 孝昌县| 太仓市| 双柏县| 洮南市| 舞阳县| 开原市| 井冈山市| 禹州市| 日土县| 五家渠市| 芦溪县| 岑溪市| 蓬安县| 定陶县| 鱼台县| 日照市| 宁晋县| 汾西县| 荆州市| 鸡东县| 昆明市| 营山县| 彭山县| 汾阳市| 靖西县| 乐都县|