cancel
Showing results for 
Search instead for 
Did you mean: 

how to add on_click event to a Hyperlink in ALV report?

Ritwisha
Discoverer
0 Kudos
61
*method prepare_data
IF lt_fu_root IS NOT INITIAL.
              lt_fu_root_temp = lt_fu_root.
              <lfs_output>-tor_id_fu = VALUE #( lt_fu_root_temp[ tor_cat = lc_fu ]-tor_id OPTIONAL ).

* Shipment tracking link
              CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
                EXPORTING
                  input  = <lfs_output>-tor_id_fu
                IMPORTING
                  output = lv_tor_id_fu_ext.

              " Concatenate the base link with the converted value
              CONCATENATE lc_link lv_tor_id_fu_ext INTO <lfs_output>-tracking_link.
            ENDIF.

I am a newbie in abap, Please help me to add the hyperlink's on click event so that when I click on the hyperlink in the report, it should direct to the browser. I have an existing report where inside method: prepare_data, I am fetching the hyperlink of this field in the final internal table.
Now, in the method: display_alv, 

Please help to add the on_click event here so that when i click on the link in the field "Tracking_link", the urls should be directing to a web browser.

 

View Entire Topic
Ritwisha
Discoverer
0 Kudos
METHOD display_alv.

    DATA: ls_key           TYPE salv_s_layout_key,
          lo_columns       TYPE REF TO cl_salv_columns_table,
          lo_event_handler TYPE REF TO lcl_customs,
          lo_column        TYPE REF TO cl_salv_column_table.

    CONSTANTS: lc_standard TYPE sypfkey VALUE 'STANDARD'.

    IF gt_output IS NOT INITIAL.
      "Preparation for the ALV
      TRY.
          cl_salv_table=>factory(
          IMPORTING
            r_salv_table = DATA(lo_salv_table)        "Salv Object
          CHANGING
            t_table      = gt_output ).         "output
        CATCH cx_salv_msg INTO DATA(lv_message).
          MESSAGE lv_message TYPE gc_succ DISPLAY LIKE gc_err.
      ENDTRY.

      DATA(lo_functions) = lo_salv_table->get_functions( ).
      lo_functions->set_all( abap_true ).

* Get Columns for ALV
      CALL METHOD lo_salv_table->get_columns
        RECEIVING
          value = lo_columns.

      lo_columns->set_optimize( abap_true ).

* Layout
      DATA(lo_layout) = lo_salv_table->get_layout( ).
      lo_layout->set_save_restriction( if_salv_c_layout=>restrict_none ).
      ls_key-report = sy-repid.
      lo_layout->set_key( ls_key ).

* Get column shipment tracking link
      TRY.
lo_columns->get_column( 'TRACKING_LINK'  )->set_short_text( '' ).
      lo_columns->get_column( 'TRACKING_LINK'  )->set_medium_text( '' ).
      lo_columns->get_column( 'TRACKING_LINK'  )->set_long_text( TEXT-059 ).
      lo_column ?= lo_columns->get_column( columnname = 'TRACKING_LINK' ).
      lo_column->set_cell_type( value = if_salv_c_cell_type=>hotspot ).
CATCH cx_salv_not_found INTO DATA(lo_msg).
          MESSAGE : lo_msg->get_longtext( ) TYPE gc_succ DISPLAY LIKE gc_err.
      ENDTRY.