Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

Inserting HYPERLINKS in ALV:

ALV provides you a very easy way of inserting hyper links in the grid.

Step 1.
Create an internal table of type LVC_T_HYPE of line type LVC_S_HYPE.It is the table that contains the HYPERLINKS.

Step 2.
Populate the table with the required links.

Step 3.
Add a field of type int4 to your structure, for each field for which you need to create the hyperlink.
These fields contains the handle to get the information from the HYPERLINK table.

Step 4.
You state the field name which contains handle for each field that will contain hyperlink,
in the field catalog by putting the handle name to the "WEB_FIELD" field for each column.

Step 5.
Populate the data table with the handle number for each field by looping it.

Step 6.
Pass the table name to the exporting parameter 'it_hyperlink' of the
method SET_TABLE_FOR_FIRST_DISPLAY.

Example:

REPORT zalv_hyperlink.
DATA:
BEGIN OF t_itab OCCURS 0.
INCLUDE STRUCTURE sflight.
DATA carrid_handle TYPE int4.
DATA END OF t_itab.
DATA:
r_container TYPE REF TO cl_gui_custom_container,
r_grid TYPE REF TO cl_gui_alv_grid.
DATA:
t_hype_link TYPE lvc_t_hype,
fs_hype_link TYPE lvc_s_hype.
DATA:
t_fcat TYPE lvc_t_fcat,
fs_fcat TYPE lvc_s_fcat.
fs_fcat-fieldname = 'CARRID'.
fs_fcat-web_field = 'CARRID_HANDLE'.
APPEND fs_fcat TO t_fcat.
fs_hype_link-handle = '1' .
fs_hype_link-href = 'www.google.com' .
APPEND fs_hype_link TO t_hype_link.
SELECT * FROM sflight INTO TABLE t_itab.
LOOP AT t_itab .
IF t_itab-carrid = 'AA'.
t_itab-carrid_handle = '1' .
ENDIF.
MODIFY t_itab.
ENDLOOP.
CALL SCREEN 100.
&---------------------------------------------------------------------
*& Module STATUS_0100 OUTPUT
&---------------------------------------------------------------------

MODULE status_0100 OUTPUT.
SET PF-STATUS 'SCREEN1'.ENDMODULE. " STATUS_0100 OUTPUT
&---------------------------------------------------------------------
*& Module USER_COMMAND_0100 INPUT
&---------------------------------------------------------------------

MODULE user_command_0100 INPUT.
CASE sy-ucomm.WHEN 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
&---------------------------------------------------------------------
*& Module LIST OUTPUT
&---------------------------------------------------------------------

MODULE list OUTPUT.
CREATE OBJECT r_container
EXPORTING
container_name = 'CONTAINER'.CREATE OBJECT r_grid
EXPORTING
i_parent = r_container.
CALL METHOD r_grid->set_table_for_first_display
EXPORTING
i_structure_name = 'SFLIGHT'
it_hyperlink = t_hype_link
CHANGING
it_fieldcatalog = t_fcat
it_outtab = t_itab[].
ENDMODULE. " LIST OUTPUT

Result:

List display:

  • No labels