How to disable/enable Select Options on Radiobutton action in Web Dynpro ABAP
How to disable/enable Select Options on Radiobutton: Application to enable/disable select options on Radio button action in Web Dynpro ABAP
I would like to explain the functionality of how to enable or disable select screen elements on radio button selection in Web dynpro ABAP
Example: I have considered the selection screen ui elements – Customer & Sales Document and radio buttons – Customer data & Sales data
Here, I have designed selection screen for 2 input fields viz Customer & Sales Document
Now, upon selection a radio button, the respective input field should be open for input and other to be as non-editable
Basic knowledge of Webdynpro ABAP, Using Select Options in WDA & OO ABAP
Step by step Process
Go to t-code SE80 and create a Web Dynpro component as below
Go to the used components tabl of the WDA component and create a component usage for WDR_SELECT_OPTIONS component as below
Open the view and go to the properties tab and click on create button to create an instance of used component as below
Now, choose the component usage name “SELECT_OPTIONS” by doubl clicking on the entry as shown below
The instance of component usage is created in view V_MAIN as below
Go to the “Context” tab of view and Create a context node “RADIO_BUTTONS” as shown below
Create an attribute “TEXT” in the context node “RADIO_BUTTONS” as shown below
Go the view layout tab and create an ui element “RadioButtonGroupByIndex” as shown below
Bind the property “text” to context attribute and create an action and bind it to the event “OnSelect” as shown below
Create a view container ui element “VCU_SELECT_OPTIONS” to hold the selection screen component as below
Go to attributes tab and add the attributes as shown below
Go to methods tab and create a method “CONFIG_SEL_OPTIONS” to configure selection screen elements as below
Add the below code in method CONFIG_SEL_OPTIONS
|METHOD config_sel_options .
DATA lo_componentinterface TYPE REF TO if_wd_component_usage.
wd_this->m_handler = wd_this->wd_cpifc_select_options( ).
wd_this->m_sel_options = wd_this->m_handler->init_selection_screen( ).
IF wd_this->m_sel_options IS NOT BOUND.
DATA lv_kunnr TYPE REF TO data.
CREATE DATA lv_kunnr TYPE kunnr.
We need to fill the radio buttons texts and initialize the selection screen. Hence add the below code in view initialization method “WDDOINIT( )”
|METHOD wddoinit .
DATA lo_nd_radio_buttons TYPE REF TO if_wd_context_node.
DATA lt_radio_buttons TYPE wd_this->elements_radio_buttons.
“get radio button node reference
On selection of radio buttons, we need to set the read_only property of selection screen elements. hence add the below code in event handler method ONACTIONRADIO_SELECT
|METHOD onactionradio_select .
DATA lv_index TYPE i.
” get the index of radio button
Open window W_MAIN and embed the view from select options component as below
Now, Activate the whole component
Create an application as shown below
Now, we are ready to see Output:
Initially, the output looks as below i.e. default Customer radio button is selected and Sales Document input field is non-editable
Onselect of “Sales Order” radio button, the input field “Customer” goes non-editable and making the “Sales Document” as editable as shown below
Hope this document would be useful for those looking for enabling/disabling selection screen elements based on some action
I appreciate your comments/feedback/suggestions