How to Create a Hotspot Field in OOPS ALV Report

How to Create a Hotspot Field in OOPS ALV Report



A hotspot in ALV is similar to hyperlink. A hotspot field can be used to trigger or call any event. It can be used as interactive ALV.

To create a hotspot, we need two reference variables of below classes.

·        CL_SALV_COLUMNS_TABLE - Columns instance

·        CL_SALV_COLUMN_TABLE   - Single Column instance

Steps to create hotspot field in ALV.

1.      Call ALV factory method using ALV class CL_SALV_TABLE to get ALV instance.

2.      GET COLUMNS from ALV instance

3.      GET COLUMN using column name from columns obtained in above step

4.      SET CELL TYPE as hotspot for the single column obtained above

5.      Call DISPLAY method from CL_SALV_TABLE to display the ALV output.

The operator ‘ ?= ’ is used to call the super class method. The super class for CL_SALV_COLUMNS_TABLE is CL_SALV_COLUMNS.

Example Program:

REPORT ztest_alv.

TYPESBEGIN OF ty_bkpf,
         bukrs 
TYPE bukrs,
         belnr 
TYPE belnr_d,
         gjahr 
TYPE gjahr,
         xblnr 
TYPE xblnr1,
       
END OF ty_bkpf.

DATAit_bkpf TYPE TABLE OF ty_bkpf.

DATAlo_alv     TYPE REF TO cl_salv_table,
      lo_columns 
TYPE REF TO cl_salv_columns_table,
      lo_column  
TYPE REF TO cl_salv_column_table.


START-OF-SELECTION.

  
SELECT bukrs belnr gjahr xblnr
    
FROM bkpf
    
INTO TABLE it_bkpf
    
UP TO 10 ROWS.
  
IF sy-subrc IS INITIAL.

*1. GET ALV INSTANCE.
    cl_salv_table
=>factory(
      
IMPORTING
        r_salv_table   
lo_alv
      
CHANGING
        t_table        
it_bkpf[]
    
).

*2. GET COLUMNS FROM ALV INSTANCE
    lo_columns 
lo_alv->get_columns( ).

*3. GET BUKRS COLUMN USING FIELD NAME FROM COLUMNS
    lo_column ?= lo_columns
->get_columncolumnname 'BUKRS' ).

*4. SET THE HOTSPOT FOR BUKRS COLUMN
    lo_column
->set_cell_type(
        
value if_salv_c_cell_type=>hotspot
    
).

*5. DIPLAY ALV OUTPUT
    lo_alv
->display( ).

  
ENDIF
.

Output


Post a Comment

Previous Post Next Post