cancel
Showing results for 
Search instead for 
Did you mean: 

Link to action in editable ALV

Former Member
0 Kudos

Hi experts,

I have an editable alv with a column where I implemented the UI Element "Linktoaction" for the cells of this column. I implemented it in the WddoInit-Method in my view with the alv:

lr_column_settings ?= l_value.

lr_column = lr_column_settings->get_column( 'LINK' ).

CREATE OBJECT lr_linktoaction.

lr_linktoaction->set_text( value = 'Go to Detail' ).

If I have an normal InputField I need:

lr_column->set_cell_editor( lr_input_field ).

What have I to do for getting an action for clicking on the Link? The link with the text "Go to Detail" is displayed in the editable alv. But how can I navigate to another view by clicking?

Thanls a lot for your help!!

Best Regards

Ingmar

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Ingmar.

You have to create en event handler for the on_click event of the ALV.

When the link to ation element is clicked this handler will be called.

Cheers,

Sascha

Former Member
0 Kudos

Thanks for your reply Sascha!

My problem is, where have I to implement the On-Click eventhandler? In the view, where my ALV is, I think. But how can I bind it to the linktoaction? In an editable ALV I have nothing like a UIElement in the Layout. I only define the linktoaction in my method wddoinit.

Best Regards

Ingmar

Message was edited by:

Ingmar Kroll

Former Member
0 Kudos

Yes you can implement it in the view that contains your ALV.

AFAIK no binding is necessary. The on_click method will be called.

Check out component SALV_WD_TEST_DATATYPES. In the component controller is the event_handler method for on_click event. There is the r_param inport parameter which can be used to find out which column triggered the event.

Cheers,

Sascha

karsten_heth
Active Participant
0 Kudos

Ingmar,

the ALV has an event ON_CLICK, you only have to register this event. Try this:

- Add a new method "on_click" in the view where your ALV is

- Set Method Type to "Event Handler"

- Set cursor into column "Event" and press F4 to get a list of events

- Select the ON_CLICK event of the ALV (if it's not in the list, a component usage of the ALV is missing in your view)

As already mentioned, this method has two parameters which offer all the details you need (which column was clicked, which line was clicked etc.)

Regards,

Karsten

Answers (1)

Answers (1)

0 Kudos

Hi Ingmar,

Implement 'ON_CLICK_EVENT' in the same view where u have ALV. Clicking on the link in the cell using link to action gives you the following information which u can use (pass to other view etc..) -

COLUMN_ID

INDEX

ATTRIBUTE

VALUE

You can read these values and store them in a node.

Create one node in the view by name 'EVENT_PROPERTIES' with attributes 'NAME' and 'VALUE' of type string both and use the below code in on_click_event. Here I am navigating to the next view after clicking the link, you can do whatever u want depending on ur requirement.

DATA: lr_node TYPE REF TO if_wd_context_node,

lt_event_properties TYPE if_models_list_view=>elements_event_properties,

ls_event_properties TYPE if_models_list_view=>element_event_properties.

FIELD-SYMBOLS: <l_value> TYPE ANY.

  • fill internal table

ls_event_properties-name = 'COLUMN_ID'.

ls_event_properties-value = r_param->column.

APPEND ls_event_properties TO lt_event_properties.

ls_event_properties-name = 'INDEX'.

ls_event_properties-value = r_param->index.

APPEND ls_event_properties TO lt_event_properties.

ls_event_properties-name = 'ATTRIBUTE'.

ls_event_properties-value = r_param->attribute.

APPEND ls_event_properties TO lt_event_properties.

ASSIGN r_param->value->* TO <l_value>.

ls_event_properties-name = 'VALUE'.

ls_event_properties-value = <l_value>.

APPEND ls_event_properties TO lt_event_properties.

  • navigate to context node EVENT_PROPERTIES

lr_node = wd_context->get_child_node( 'EVENT_PROPERTIES' ).

  • bind internal table to context node

lr_node->bind_table( lt_event_properties ).

wd_this->fire_to_pi_main_view_plg( ).

Regards,

Gaurav