Skip to Content
If you include the standard webdynpro ALV component SALV_WD_TABLE into your own component, you could not directly change the ALV table column as usual. In ABAP Webdynpro an example of link to action element used in ALV looks like below. Once the column “Social Media Post ID” is clicked, it is expected our application could catch the event and implement our own event handling logic.
You could follow the steps below:
1. Define the component usage to ALV component by double clicking your webdynpro component in SE80 and maintain the component usage in tab “Used Web Dynpro Components”
2. Double click the INTERFACECONTROLLER_USAGE,add your own component for ALV component usage. The reason for this is you need to map the context node of your own component to ALV component, so that it can know which data from your application should display.
After that it is ready for mapping the context node of your component to the context node DATA of ALV component. You can achieve it via drag and drop or right click on DATA node, and choose “Define External Mapping” from context menu. After mapping is done, you could see the mapping path displayed below.
3. double click on your view, and insert a new element “ViewContainerUIElement”, which acts as the container for ALV interface view to be embedded.
then double click on window, right click the ViewContainerUIElement and choose “Embed View”, include the ALV interface view from drop down list.
The final settings looks like below. Now you should already see the ALV in your application UI.
Create a new method in view controller and implement the code below:
method RENDER_HYPERLINK .
  DATA:
    lr_alv_usage       TYPE REF TO if_wd_component_usage,
    lr_if_controller   TYPE REF TO iwci_salv_wd_table,
    lr_config          TYPE REF TO cl_salv_wd_config_table,
    lr_column_settings TYPE REF TO if_salv_wd_column_settings,
    lt_columns         TYPE        salv_wd_t_column_ref,
    lr_link            TYPE REF TO cl_salv_wd_uie_link_to_action.
   lr_alv_usage = wd_this->wd_cpuse_salv_wd_table( ).
   IF lr_alv_usage->has_active_component( ) IS INITIAL.
     lr_alv_usage->create_component( ).
   ENDIF.
   lr_if_controller = wd_this->wd_cpifc_salv_wd_table( ).
   lr_config        = lr_if_controller->get_model( ).
   lr_config->if_salv_wd_table_settings~set_cell_action_event_enabled( abap_false ).
   lr_column_settings ?= lr_config.
   lt_columns = lr_column_settings->get_columns( ).
   LOOP AT lt_columns ASSIGNING FIELD-SYMBOL(<column>).
      CASE <column>-id.
        WHEN 'INTERNAL_ID'.
          CREATE OBJECT lr_link.
          lr_link->set_text_fieldname( <column>-id ).
         <column>-r_column->set_cell_editor( lr_link ).
        WHEN OTHERS.
      ENDCASE.
   ENDLOOP.
endmethod.

And call it in wddomodifyview of view controller:

METHOD wddomodifyview .
  CHECK first_time = abap_true.
  render_hyperlink( ).
ENDMETHOD.

Note: according to sap help, the event ON_CLICK is only triggered if the method IF_SALV_WD_TABLE_SETTINGS~SET_CELL_ACTION_EVENT_ENABLED is set to FALSE Otherwise, the event ON_CELL_ACTION is triggered.

4. Create a event handler in view controller Methods tab. Choose the event name ON_CLICK from drop down list.

In the runtime, the selected item index and item value could be found in importing parameter R_PARAM:

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

  1. Michelle Crapo

    Very nice!   Step by step instructions.   Yes, I’m bookmarking this one too!   I used to write Web Dynpros.   Now the thought is that they are going to be replaced by the newer technology.    So it makes me happy to read this one!

    Mihcelle

    (0) 

Leave a Reply