Trigger ALV Events in Web Dynpro Component
To trigger ALV events in Web Dynpro like ON_CLICK, ON_SELECT or ON_CELL_ACTION ABAP developer should register event handlers for corresponding event methods and should enable related events at WDDOMODIFYVIEW method of the Web Dynpro component.
In this Web Dynpro tutorial, I'll show how to register event handlers for ALV events and enable events at WDDOMODIFYVIEW method using ABAP code.
Recently I have created an SAP Web Dynpro component where I have used a dynamically created ABAP ALV table for data display. Since I need an editable ALV table, I have to use ALV events like on_cell_action, on_select event and on_click event.
Although I've registered ALV events, during debugging I realized I fail to trigger ALV events like select event or on cell action event.
This event triggering failed since I did not enable the ALV events.
After I enable those ALV events for the dynamically created ALV in Web Dynpro component at WDDOMODIFYVIEW method, I successfully managed to trigger ALV events and debug ABAP code without any problem.
Register ALV Event Handlers in Web Dynpro Component
Let's start with the first step.
In order to register these three events mentioned above, go to the View object where the ABAP developer is displaying the ALV table object.
Then switch to Methods tab as seen in below screenshot.
First select Event Handler from Method Type dropdown column.
Then press F4 or use search help on column named Event.
Choose the required event for the related component use.
Then type the method name and description for the event handler method.
Enable ALV Events in Web Dynpro WDDOMODIFYVIEW Method
Before successfully triggering ALV events, ABAP developer should modify the Web Dynpro component WDDOMODIFYVIEW method to enable ALV events. Following ABAP codes can be used to enable ALV events in WDDOMODIFYVIEW method.
set_cell_action_event_enabled and set_on_select_enabled methods are used to enable ALV events in a Web Dynpro component in WDDOMODIFYVIEW event.
Trigger ALV Events
After all steps described in above tutorial are covered, when you click on a ALV row or press Enter key on an editable ALV table cell, these event handlers will be triggered. ABAP developers can add custom code with in these ALV event handler methods.