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

Read Checkbox Value in Web Dynpro Editable ALV

This Web Dynpro tutorial shows how to retrieve value of a checkbox control in editable ALV table in a Web Dynpro component. To read checkbox value and identify if it is marked or unmarked (cleared), ABAP programmers can use ALV event like ON_CELL_ACTION and R_PARAM parameter value R_PARAM->VALUE

I register ALV events and enable them in WDDOMODIFYVIEW method. When the SAP user clicks on checkbox control displayed on an editable ALV control in Web Dynpro component, I can catch the user interaction using the ON_CELL_ACTION event handler of the ALV control.

R_PARAM parameter of the Event provides ABAP developer all required information about the event details triggered like the row index, column name and the value of the column, etc.

For example, if you put a break point and debug your Web Dynpro code you can watch the R_PARAM values as follows:

on_cell_action event parameters to get value of checkbox in ALV

R_PARAM->INDEX is showing the index of the row displayed on the ALV table on Web Dynpro page.

R_PARAM->COLUMN is showing the name of the column that the cell triggering the event belongs to.

R_PARAM->VALUE event parameter attribute gives the value of the checkbox control to the ABAP developer. ABAP developer can retrieve the checkbox value, or identify if the checkbox is marked or cleared by using the R_PARAM->VALUE

Unfortunately, developers can see the checkbox value on the debugger screen using R_PARAM->VALUE in order to use this in ABAP codes following syntax should be used.

*** --> if checkbox is marked or cleared, P_ALL_NONE parameter is populated with data
data LV_ALL_NONE type C1. " default initial
field-symbols: <FS> type DATA.

if R_PARAM->COLUMN = 'CHECKBOXMARKED'. " ALV column name with checkbox in its cells

 assign R_PARAM->VALUE->* to <FS>.

 if <FS> = 'X'.
  LV_ALL_NONE = 'A'.
 else.
  LV_ALL_NONE = 'N'.
 endif.

endif.
*** <-- read checkbox value (END)
Code

The R_PARAM->VALUE should be assigned to a field symbol and the value of this field symbol should be used within ABAP control statements.

Using field symbol in <FS> = 'X' equality shows that the checkbox created in editable ALV table is marked. Otherwise developers can assume that the checkbox is cleared or unmarked.

If you directly compare R_PARAM->VALUE with 'X' to check if the checkbox is marked or not, developers will get the ABAP exception saying that:
cant compare 'X' and R_PARAM->VALUE



SAP HANA and ABAP

Install SAP Free
CRM Companies List
Web Based CRM Software


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