SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software
Development resources, articles, tutorials, code samples, tools and downloads for SAP HANA and ABAP, HANA Database, SQLScript, SAP UI5, Screen Personas, Web Dynpro, Workflow

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.

register ALV event handlers in Web Dynpro

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.

*** Enable On_Cell_Action event of ALV
* Data Declaration

data lo_interfacecontroller type ref to iwci_salv_wd_table .
data lo_value type ref to cl_salv_wd_config_table.

* Instantiate ALV

lo_interfacecontroller = wd_this->wd_cpifc_alv_openitems( ).

* Call get_model of Interface Controller to get reference of ALV
lo_value = lo_interfacecontroller->get_model( ).

* Enable the ON_CELL_ACTION Event
call method lo_value->if_salv_wd_table_settings~set_cell_action_event_enabled
  value = ABAP_TRUE .

* Enable the ON_SELECT Event
call method lo_value->if_salv_wd_table_settings~set_on_select_enabled
  value = ABAP_TRUE .

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.


Install SAP Free
CRM Companies List
Web Based CRM Software

Copyright © 2004 - 2021 Eralper YILMAZ. All rights reserved.