SALV Table 8 – Add & Handle Hotspot

By | September 28, 2008 | SALV Table, SALV Tutorial, Tutorials | 83,641 | 7

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
    DATAlo_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
    DATAlo_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.
*
    DATAla_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(00WITH '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:

Like It? Share!!

Don't miss an Update

Get notified of the new post, right into your inbox

Naimesh Patel{274 articles}

I'm SAP ABAP Consultant for more than a decade. I like to experiment with ABAP especially OO. I have been SDN Top Contributor.
Follow :

Explore all of his 274 articles.

Load comments

7 Comments

  • Anonymous

    please send me sample code where the above code has implemented…

  • Hello

    please send me sample code where the above code has implemented…

    As mentioned in this post, visit:

    SALV Model 1: Normal ALV Table Display.

    Regards,
    Naimesh Patel

  • Anonymous

    This can help me about my current projects. Can you send me a full code of this sample alv

    here's my email: charsags@yahoo.com

    thanks,
    charles

  • Hello Charles,

    Please use the code provided in SALV Model 1: Normal ALV Table Display to apply the nuggets provided here…

    Regards,
    Naimesh Patel

  • Hi Patel,

    This code is very useful and easy to understand.

    For my requirement I want to show another ALV when I am click on vbeln. It should take it to that ALV, has related fields to vbeln.

    Can you help me to do this.

    Regards,
    Bharani

  • Hello Naimesh Patel

    I impletmented the Initial Sample ALV it worked fine. But I am getting errors when I used the Hotspot functionality.

    Can you please mail the entire code for Hot spot and drill down functionality. I need to use the same in on of my deliverables.

    I have done normal ALV using OOPS concepts but wanted to try using the factory method.

    Please mail me the source code to rameshsa@yahoo.com or ramesh.segavalu@gmail.com

    Otherwise the blog is very good and good initiative.

    Thanks so much in advance.
    Ramesgh

  • […] you have seen in past, in post SALV Table 8 – Add & Handle Hotspot on how to create the HOTSPOT on the single column. This task is being done by the method […]

Comments on this Post are now closed. If you have something important to share, you can always contact me.

You seem to be new here. Subscribe to stay connected.