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 SAP ABAP Programming and HANA Database 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


Add Button to ALV Table Header on SAP Web Dynpro

SAP ABAP programmer can add button in SALV_WD_TABLE ALV table header displayed on Web Dynpro page and code to trigger a custom event which is catched by the ALV code. Web Dynpro developer can complete adding custom button in three steps illustrated in this tutorial.

This Web Dynpro tutorial shows how to add a button on ALV table header and add custom functions to this button like "SELECT ALL", "CLEAR ALL" or "Download", etc. Below screenshot is displaying the added custom buttons besides default, standart ALV buttons on the ALV table header on a WebDynpro page.

add button in ALV table header on Web Dynpro view

ABAP programmers can expect to end up with an above result after implementing steps illustrated in this SAP tutorial. Let's start our tutorial.


Web Dynpro ABAP code to add Button on ALV Table Header

I assume that you have created an ALV table on a Web Dynpro view ViewContainerUIElement. The ALV table is being created using the SALV_WD_TABLE component.
I will not be telling how to use SALV_WD_TABLE ALV table on a Web Dynpro component in this tutorial. Instead I'll be focusing on adding buttons on ALV table header.

ABAP developers will be modifying the WDDOMODIFYVIEW method which is the method for modifying the Web Dynpro view before rendering it for the web browser users.

Within the WDDOMODIFYVIEW method, add following code block. If you have already enabled ALV events like ON_CELL_ACTION event, ON_SELECT event, etc. following code would be partially included in your ABAP development. Then Web Dynpro developer will be required to add the code blocks related with button and code related with attached funtion to this button.

* Data Declaration
DATA lo_interfacecontroller TYPE REF TO iwci_salv_wd_table .
DATA lo_value TYPE REF TO cl_salv_wd_config_table.

lo_interfacecontroller = wd_this->wd_cpifc_alv_openitems( ).

* execute interface controller get_model() method for ALV configuration table
lo_value = lo_interfacecontroller->get_model( ).

* add BUTTON titled SELECT ALL
DATA bt_selectall TYPE REF TO cl_salv_wd_fe_button.
CREATE OBJECT bt_selectall.
bt_selectall->set_text( 'Select ALL' ).

DATA button1 TYPE REF TO cl_salv_wd_function.
button1 = lo_value->if_salv_wd_function_settings~create_function( id = 'SELECTALL' ).
button1->set_editor( bt_selectall ).

Only adding the above ABAP codes will not be enough to complete a successfully working button on ALV table header. Although it is enough to display the button within the SALV_WD_TABLE ALV table header beside standart buttons, to make it work ABAP programmers are required to configure the ALV to catch the ALV event triggered by the new button.

Web Dynpro developers can use ON_FUNCTION event of the ALV component use. In order to register the On_Function event, switch to Methods tab then add a new method in Event type as seen in below screenshot. Please note that, if you use F4 on Component Use you will be able to complete Event, Controller and Component Use by a single click.

Web Dynpro View methods for ALV table button function

As the third step, we need to code what we want to happen within the recently added method. If you look at the above screenshot, you will see that I named the method as SELECT_ALL. Double click on your method and switch to code view.

METHOD select_all .

DATA temp TYPE string.
temp = r_param->id.

* function id, I have to buttons one for SELECTALL and another for CLEARALL
IF temp = 'SELECTALL' OR temp = 'CLEARALL'.

DATA lo_componentcontroller TYPE REF TO ig_componentcontroller .
lo_componentcontroller = wd_this->get_componentcontroller_ctr( ).

CASE temp.
 WHEN 'SELECTALL'.
* execute your code here
  lo_componentcontroller->calculate_volume( p_select_all = 'X' ).
 WHEN 'CLEARALL'.
  lo_componentcontroller->calculate_volume( p_clear_all = 'X' ).
ENDCASE.

ENDIF.

ENDMETHOD.

After applying the above 3 steps within the Web Dynpro component View, ABAP developers will complete to add buttons on ALV table header successfully. I hope it will be useful for SAP programmers who want to configure SALV_WD_TABLE ALV table component and add custom buttons on table header.






SAP Tutorials

SAP Tutorial

SAP Forums

SAP Tools

SAP Transaction Codes Table






Related Articles and Tutorials(http://www.kodyaz.com/sap-abap/add-button-in-alv-table-header-on-web-dynpro.aspx)
How to Clear Web Dynpro Cache
Display Adobe Form in SAP Web Dynpro
Trigger ALV Events in Web Dynpro Component
SAP Web Dynpro ALV Tutorial
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 Button to ALV Table Header on SAP Web Dynpro
Add Web Dynpro Applications to SAP Favorites Menu
Traffic Lights in SAP Web Dynpro ALV Table
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 Data on Web DynPro Table Element
Display and Download Adobe Form as PDF File in SAP Web Dynpro
Find Web Dynpro Class Name to Search in ABAP Code
Web DynPro Tutorial - How to create Web Dynpro Application (Web Dynpro Component)
Test Web Dynpro ABAP Component by Creating Web Dynpro Application
Remove ALV Buttons on SAP Web Dynpro Component
Set Page Title in Web Dynpro Application
Web Dynpro Text Translation using Assistance Class
Read Checkbox Value in Web Dynpro Editable ALV
SAP Web Dynpro File Upload using GOS cl_fitv_gos Class
Add Value Help to Web Dynpro Select Options
Web Dynpro Component Service Syntax Error in Program /1BCWDY/O3EC1AX6A3OVKK9L5FXO==CP
Translate Web Dynpro Header Title displayed on Web Browser
Web DynPro Tutorial - Display Spool Requests using Web DynPro Table
SAP Web Dynpro Service Cannot be Reached Error
SAP - ABAP ALV Grid Sample Code using REUSE_ALV_GRID_DISPLAY


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