Hello,
I have a table that is displayed in an ALV grid and I would like to have one of the columns as clickable icons.
For example:
Print | Doc. Type | Name
--------------------------------------
(icon) | .docx | first
(icon) | .pdf | second ... and so on.
I would like to click in the icon (Print column) and execute an action, but no matter what I do I can't set the action.
I know that is not just setting "fieldcatalog-hotspot='X'", but I don't know how to use a hotspot handler.
Here's some of the code I have:
TYPES: BEGIN OF ty_docs,
print LIKE ICON-ID,
doc_type LIKE table_doc-TYPE,
name LIKE table_doc-NAME,
END OF ty_docs.
DATA: oref_dock TYPE REF TO cl_gui_docking_container,
oref_alv TYPE REF TO cl_gui_alv_grid,
i_fieldcat TYPE lvc_t_fcat,
aux_fieldcat TYPE lvc_s_fcat,
aux_lay TYPE lvc_s_layo,
i_exclude TYPE TABLE OF syucomm,
i_docs TYPE ty_docs,
t_docs LIKE TABLE OF i_docs.
AT SELECTION-SCREEN OUTPUT.
APPEND 'ONLI' TO i_exclude.
APPEND 'SJOB' TO i_exclude.
APPEND 'PRIN' TO i_exclude.
CALL FUNCTION 'RS_SET_SELSCREEN_STATUS'
EXPORTING
p_status = sy-pfkey
p_program = sy-repid
TABLES
p_exclude = i_exclude.
AT SELECTION-SCREEN.
CHECK sy-ucomm = space.
SELECT
icon~ID AS print
doc~TYPE AS doc_type
doc~NAME as name
INTO CORRESPONDING FIELDS OF TABLE t_docs
FROM table_docAS doc
INNER JOIN ICON AS icon
ON icon~NAME EQ 'ICON_PRINT'
GROUP BY icon~ID doc~TYPE doc~NAME.
IF sy-subrc = 0.
IF oref_dock IS NOT BOUND.
CREATE OBJECT oref_dock
EXPORTING
repid = sy-repid
dynnr = sy-dynnr
side = cl_gui_docking_container=>dock_at_bottom
ratio = 90
EXCEPTIONS
OTHERS = 1.
ENDIF.
IF oref_alv IS NOT BOUND.
CHECK oref_dock IS BOUND.
CREATE OBJECT oref_alv
EXPORTING
i_parent = oref_dock
EXCEPTIONS
OTHERS = 1.
CHECK oref_alv IS BOUND.
aux_fieldcat-fieldname = 'PRINT'.
aux_fieldcat-coltext = 'Print'.
aux_fieldcat-ref_table = 't_docs'.
aux_fieldcat-ref_field = 't_docs-print'.
aux_fieldcat-edit = ''.
aux_fieldcat-just = 'C'.
aux_fieldcat-hotspot = 'X'.
aux_fieldcat-outputlen = 10.
aux_fieldcat-col_pos = 0.
APPEND aux_fieldcat TO i_fieldcat.
CLEAR aux_fieldcat.
aux_fieldcat-fieldname = 'TYPE'.
aux_fieldcat-coltext = 'Doc. Type'.
aux_fieldcat-ref_table = 't_docs'.
aux_fieldcat-ref_field = 't_docs-doc_type'.
aux_fieldcat-edit = ''.
aux_fieldcat-outputlen = 15.
aux_fieldcat-col_pos = 1.
APPEND aux_fieldcat TO i_fieldcat.
CLEAR aux_fieldcat.
aux_fieldcat-fieldname = 'NAME'.
aux_fieldcat-coltext = 'Name'.
aux_fieldcat-ref_table = 't_docs'.
aux_fieldcat-ref_field = 't_docs-name'.
aux_fieldcat-edit = ''.
aux_fieldcat-outputlen = 12.
aux_fieldcat-col_pos = 2.
APPEND aux_fieldcat TO i_fieldcat.
CLEAR aux_fieldcat.
aux_lay-grid_title = 'Docs'.
aux_lay-edit = ''.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'ty_docs'
i_internal_tabname = 't_docs'
CHANGING
ct_fieldcat = i_fieldcat
EXCEPTIONS
OTHERS = 3.
CALL METHOD oref_alv->set_table_for_first_display
EXPORTING
i_structure_name = 'ty_docs'
is_layout = aux_lay
CHANGING
it_fieldcatalog = i_fieldcat
it_outtab = t_docs
EXCEPTIONS
OTHERS = 1.
ELSE.
CALL METHOD oref_alv->refresh_table_display
EXCEPTIONS
OTHERS = 1.
ENDIF.
ENDIF.
Thank you so much in advance!