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

Remove ALV Buttons on SAP Web Dynpro Component

In this SAP Web Dynpro tutorial I share ABAP codes showing how to remove standard ALV buttons like APPEND, INSERT or DELETE with ABAP programmers. On default view of an Web Dynpro ALV there are a numerous buttons which developers can require to hide or remove from ALV table. Using ALV object Get_Model() method and using the methods from IF_SALV_WD_STD_FUNCTIONS interface ABAP programmers can customize the buttons on an SAP Web Dynpro component.

I'm using SALV_WD_TABLE ALV Component to display an internal table data on a SAP Web Dynpro page. Here is how ALV data is displayed with default settings.

ALV table with default buttons on SAP Web Dynpro component

As you see the following ALV buttons are displayed by default when the Web Dynpro page is displayed. Since I do not want a ALV functionality like Append Row, Insert Row or Delete Row on this SAP Web Dynpro component, I will hide these buttons or remove them using ALV configuration methods.

Web Dynpro ALV table buttons like Append, Insert and Delete Row

Following ABAP code fetches the model for the ALV which I will use for configuration of default buttons. This ABAP code will help me to remove ALV buttons that I do not need here in this case Append, Insert and Delete buttons for example.

*******************************************
*** Configure ALV for default buttons
*******************************************

* Instantiate used component ALV
data LO_CMP_USAGE type ref to IF_WD_COMPONENT_USAGE.
LO_CMP_USAGE = WD_THIS->WD_CPUSE_ALV_OPENITEMS( ).
if LO_CMP_USAGE->HAS_ACTIVE_COMPONENT( ) is initial.
 LO_CMP_USAGE->CREATE_COMPONENT( ).
endif.

* Get ALV configuration settings using used controller method GET_MODEL.
data LO_INTERFACECONTROLLER type ref to IWCI_SALV_WD_TABLE .
LO_INTERFACECONTROLLER = WD_THIS->WD_CPIFC_ALV_OPENITEMS( ).

data LV_VALUE type ref to CL_SALV_WD_CONFIG_TABLE.
LV_VALUE = LO_INTERFACECONTROLLER->GET_MODEL( ).
Code

After this line in ABAP code, ABAP programmers can use one of the below two ABAP code blocks to configure visibility of default ALV buttons on Web Dynpro page.

data: LR_STD type ref to IF_SALV_WD_STD_FUNCTIONS.
LR_STD ?= LV_VALUE.
LR_STD->SET_EXPORT_ALLOWED( ABAP_TRUE ).
LR_STD->SET_EDIT_CHECK_AVAILABLE( ABAP_FALSE ).
LR_STD->SET_EDIT_INSERT_ROW_ALLOWED( ABAP_FALSE ).
LR_STD->SET_EDIT_APPEND_ROW_ALLOWED( ABAP_FALSE ).
LR_STD->SET_EDIT_DELETE_ROW_ALLOWED( ABAP_FALSE ).
Code

Or change the allowed or available attributes by using the ABAP_TRUE or ABAP_FALSE values as follows.

LV_VALUE->IF_SALV_WD_STD_FUNCTIONS~SET_EXPORT_ALLOWED( ABAP_TRUE ).
LV_VALUE->IF_SALV_WD_STD_FUNCTIONS~SET_EDIT_CHECK_AVAILABLE( ABAP_FALSE ).
LV_VALUE->IF_SALV_WD_STD_FUNCTIONS~SET_EDIT_INSERT_ROW_ALLOWED( ABAP_FALSE ).
LV_VALUE->IF_SALV_WD_STD_FUNCTIONS~SET_EDIT_APPEND_ROW_ALLOWED( ABAP_FALSE ).
LV_VALUE->IF_SALV_WD_STD_FUNCTIONS~SET_EDIT_DELETE_ROW_ALLOWED( ABAP_FALSE ).
Code

After ABAP programmers make changes on their codes and activate Web Dynpro component, resultant ALV table will be as follows. As seen in below screenshot Export button is allowed on the other hand Check, Append Row, Insert Row and Delete Row buttons are disabled and removed from the ALV table.

SAP Web Dynpro ALV table with buttons removed



SAP HANA and ABAP

Install SAP Free
CRM Companies List
Web Based CRM Software


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