In the series of the SALV model table display, today we will see how to add the hotspot and after adding, how to handle that hotspot. You can find all the previous discussion at Tutorials > SALV Table Display.
Hotspot is useful in most of the ALV reports to drill-down from the main list. For example, in the Sales order report, it would be great if we provide a drill-down to VA03 (Sales Order display). By this way users would have better flexibility to look into the respective document information.
To add the Hotspot, we need to get the object reference of the CL_SALV_COLUMNS_TABLE from the ALV object (reference to CL_SALV_TABLE). This object reference contains the properties related to ALL the columns. For implementing HOTSPOT, we need to change the specific column properties (i.e. Sales Order or Customer). For this purpose, we need to have an access of the object reference CL_SALV_COLUMN_TABLE - which will contain the properties of the speicific column. We will set the specific Cell type for the HOTSPOT. Here we will use the Casting concept of the Object Oriented to refer the properties of the CL_SAL_COLUMN_TABLE. Read this for casting: ABAP OBjects - Narrowing Cast & ABAP Objects: Widening Cast
Ater implementing the Hotspot, we need to implement the Event Hanlder to handle the Hotspot. Here, we will implement the event listner method for the event LINK_CLICK of the class CL_SALV_EVENTS_TABLE. We need to set the handler of this events to let the system know, where to go when the event occurs.
Note: Here we have used the class CL_SALV_COLUMNS_TABLE which is different than the class CL_SALV_COLUMNS discussed as in the previous post SALV Model 7 - Changing Column settings.
Here is the code snippet to which provides the ADD-ON code to our Base program. The base program can be found in the SALV Model 1: Normal ALV Table Display.
UML Diagram would be like:
Code Snippet for Hotspot and event handling |
*$*$*.....CODE_ADD_1 - Begin..................................1..*$*$* * * In this section we will define the private methods which can * be implemented to set the properties of the ALV and can be * called in the * PRIVATE SECTION. * Set the various column properties METHODS: set_hotspot_vbeln CHANGING co_alv TYPE REF TO cl_salv_table co_report TYPE REF TO lcl_report. * * Event Handler for HOTSPOT event METHODS: on_link_click FOR EVENT link_click OF cl_salv_events_table IMPORTING row column . *$*$*.....CODE_ADD_1 - End....................................1..*$*$* * * *$*$*.....CODE_ADD_2 - Begin..................................2..*$*$* * * In this area we will call the methods which will set the * different properties to the ALV * * Set Up the Hotspot & Event Handler CALL METHOD set_hotspot_vbeln CHANGING co_alv = o_alv co_report = lo_report. *$*$*.....CODE_ADD_2 - End....................................2..*$*$* * * *$*$*.....CODE_ADD_3 - Begin..................................3..*$*$* * * In this area we will implement the methods which are defined in * the class definition * METHOD set_hotspot_vbeln. * *...HotSpot DATA: lo_cols_tab TYPE REF TO cl_salv_columns_table, lo_col_tab TYPE REF TO cl_salv_column_table. * * get Columns object lo_cols_tab = co_alv->get_columns( ). * * Get VBELN column TRY. lo_col_tab ?= lo_cols_tab->get_column( 'VBELN' ). CATCH cx_salv_not_found. ENDTRY. * * Set the HotSpot for VBELN Column TRY. CALL METHOD lo_col_tab->set_cell_type EXPORTING value = if_salv_c_cell_type=>hotspot. . CATCH cx_salv_data_error . ENDTRY. * *...Events DATA: lo_events TYPE REF TO cl_salv_events_table. * * all events lo_events = o_alv->get_event( ). * * event handler SET HANDLER co_report->on_link_click FOR lo_events. * ENDMETHOD. "set_hotspot_vbeln * * Handles the UI on the VBELN (HotSpot) METHOD on_link_click. * DATA: la_vbak TYPE ty_vbak. * * Get the Sales Order number from the table READ TABLE lo_report->t_vbak INTO la_vbak INDEX row. IF la_vbak-vbeln IS NOT INITIAL. MESSAGE i398(00) WITH 'You have selected' la_vbak-vbeln. ENDIF. * ENDMETHOD. "on_link_click * *$*$*.....CODE_ADD_3 - End....................................3..*$*$*
|
This code will generate output like this:
After event handling of the Hotspot:
0 comments
Post a Comment