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 Kodyaz SAP and ABAP Programming Tutorials
Development resources, articles, tutorials, samples, codes and tools for .Net, SQL Server, Windows, Windows Phone, SAP and ABAP, like SAP UI5, Screen Personas, etc.




CRM Companies List
Web Based CRM Software


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_CMP_USAGE type ref to IF_WD_COMPONENT_USAGE.

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

* Instantiate ALV
LO_CMP_USAGE = WD_THIS->WD_CPUSE_ALV_OPENITEMS( ).
if LO_CMP_USAGE->HAS_ACTIVE_COMPONENT( ) is initial.
 LO_CMP_USAGE->CREATE_COMPONENT( ).
endif.

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
 exporting
  value = ABAP_TRUE .

* Enable the ON_SELECT Event
call method lo_value->if_salv_wd_table_settings~set_on_select_enabled
 exporting
  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.






SAP Tutorials

SAP Tutorial

SAP Forums

SAP Tools

SAP Transaction Codes Table






Related Articles and Tutorials(http://www.kodyaz.com/sap-abap/trigger-web-dynpro-alv-events.aspx)
Display Adobe Form in SAP Web Dynpro
Set Page Title in Web Dynpro Application
Add Value Help to Web Dynpro Select Options
Translate Web Dynpro Header Title displayed on Web Browser
SAP Web Dynpro Service Cannot be Reached Error
Display Data on Web DynPro Table Element
Find Web Dynpro Class Name to Search in ABAP Code
How to Clear Web Dynpro Cache
Remove ALV Buttons on SAP Web Dynpro Component
Web Dynpro Text Translation using Assistance Class
Trigger ALV Events in Web Dynpro Component
SAP Web Dynpro ALV Tutorial
Read Checkbox Value in Web Dynpro Editable ALV
Add Button to ALV Table Header on SAP Web Dynpro
Traffic Lights in SAP Web Dynpro ALV Table
Create CL_GUI_ALV_GRID ALV Grid Column Header using ABAP Data Element
Multi Color ALV Grid Color Alternate using ALV Layout info_fname Property
ALV Grid Color - Table Row Background Color in ALV List
SAP ABAP Tutorial - ALV Grid Example with cl_gui_alv_grid and Screen Painter
Add Web Dynpro Applications to SAP Favorites Menu
Component Usage ALV Does Not Have an Active Component
Create Search Help in ABAP for Web Dynpro Component
Create Transaction Code for Web Dynpro Application
Display and Download Adobe Form as PDF File in SAP Web Dynpro
Web DynPro Tutorial - How to create Web Dynpro Application (Web Dynpro Component)
Test Web Dynpro ABAP Component by Creating Web Dynpro Application
SAP Web Dynpro File Upload using GOS cl_fitv_gos Class
Web Dynpro Component Service Syntax Error in Program /1BCWDY/O3EC1AX6A3OVKK9L5FXO==CP
Web DynPro Tutorial - Display Spool Requests using Web DynPro Table
SAP - ABAP ALV Grid Sample Code using REUSE_ALV_GRID_DISPLAY


Copyright © 2004 - 2017 Eralper YILMAZ. All rights reserved.
Community Server by Telligent Systems