cancel
Showing results for 
Search instead for 
Did you mean: 

How to use RADIO BUTTONS and SELECT OPTIONS

former_member295881
Contributor
0 Kudos

Hello Experts,

I’m a rookie to Web Dynpro and struggling to use RADIO BUTTON with SELECT OPTIONS together. I’ve been following a few examples about how to create SELECT OPTIONS and retrieve data based on user input. For reference here is my code which I wrote on WDDOINIT method of my view.

method WDDOINIT .

DATA: lt_range_table    TYPE REF TO data,
read_only        
TYPE        abap_bool,
typename         
TYPE        string.

DATA: lr_componentcontroller    TYPE REF TO ig_componentcontroller,
l_ref_cmp_usage          
TYPE REF TO if_wd_component_usage.

* create the used component
l_ref_cmp_usage
= wd_this->wd_cpuse_select_options( ).
IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.
l_ref_cmp_usage
->create_component( ).
ENDIF.

* get a pointer to the interface controller of the select options component
wd_this
->m_wd_select_options = wd_this->wd_cpifc_select_options( ).

* init the select screen
wd_this
->m_handler = wd_this->m_wd_select_options->init_selection_screen( ).

* create a range table that consists of this new data element
lt_range_table
= wd_this->m_handler->create_range_table(
i_typename
= 'S_CARR_ID' ).
* add a new field to the selection
wd_this
->m_handler->add_selection_field(
i_id
= 'S_CARR_ID'
it_result
= lt_range_table
i_read_only
= read_only ).

* create a range table that consists of this new data element
lt_range_table
= wd_this->m_handler->create_range_table(
i_typename
= 'S_CONN_ID' ).
* add a new field to the selection
wd_this
->m_handler->add_selection_field(
i_id
= 'S_CONN_ID'
it_result
= lt_range_table
i_read_only
= read_only ).
endmethod.

The problem is based on the requirement I need to have a RADIO BUTTON and when user click on it ONLY THEN select option should be enable. This is where I’m totally lost and can’t figure out what I should do next.  Can anybody please help me to accomplish it?

Attached is the screen shot of how selection screen should looks like.

Many thanks in advance.

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member295881
Contributor
0 Kudos

Many thanks guys for such a great help. I've learn more based on provided links and code and changed my code like this. On WDDOINIT I disable select options as below.

-----------------------------------------------------------------------------------------------------------------

method WDDOINIT .

data: lo_nd_radio_node1   type ref to if_wd_context_node,
       ls_radio_node1      type        wd_this->element_radio_node1,
       t_radio_node1       type        if_main=>elements_radio_node1.

   ls_radio_node1 = 'CARR_ID'.
     append ls_radio_node1 to t_radio_node1.

   ls_radio_node1 = 'CONN ID'.
     append ls_radio_node1 to t_radio_node1.


*" navigate from <CONTEXT> to <RADIO_NODE1> via lead selection
    lo_nd_radio_node1 = wd_context->get_child_node( name = wd_this->wdctx_radio_node1 ).

*" Call method bind table and pass the table t_radio_node1 to display text
   call method lo_nd_radio_node1->bind_table
     exporting
         new_items  = t_radio_node1.

DATA: lt_range_table    TYPE REF TO data,
       read_only         TYPE        abap_bool,
       typename          TYPE        string.

DATA: lr_componentcontroller    TYPE REF TO ig_componentcontroller,
       l_ref_cmp_usage           TYPE REF TO if_wd_component_usage.

* create the used component
   l_ref_cmp_usage = wd_this->wd_cpuse_select_options( ).
    IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.
      l_ref_cmp_usage->create_component( ).
    ENDIF.

* get a pointer to the interface controller of the select options component
   wd_this->m_wd_select_options = wd_this->wd_cpifc_select_options( ).

* init the select screen
   wd_this->m_handler = wd_this->m_wd_select_options->init_selection_screen( ).

* create a range table that consists of this new data element
   lt_range_table = wd_this->m_handler->create_range_table(
                                         i_typename = 'S_CARR_ID' ).
* add a new field to the selection
  wd_this->m_handler->add_selection_field(
                                          i_id = 'S_CARR_ID'
                                          it_result = lt_range_table
                                          i_read_only = abap_true ). "read_only

* create a range table that consists of this new data element
   lt_range_table = wd_this->m_handler->create_range_table(
                                        i_typename = 'S_CONN_ID' ).
* add a new field to the selection
   wd_this->m_handler->add_selection_field(
                                           i_id = 'S_CONN_ID'
                                           it_result = lt_range_table
                                           i_read_only = abap_true ). "read_only


endmethod.

----------------------------------------------------------------------------------------------------------------

Now when user select the Radio button where I want to enable Select options I wrote the following code on Radio button's action ONACTIONENABLE_DISABLE.

-----------------------------------------------------------------------------------------------------------------

method ONACTIONENABLE_DISABLE .

  DATA lo_nd_radio_node1   TYPE REF TO if_wd_context_node.
  DATA lo_el_radio_node1   TYPE REF TO if_wd_context_element.
  DATA lw_index            TYPE I.
  DATA lo_el_radio_node2_1 TYPE ref to if_wd_context_element.
  DATA lr_data             TYPE REF TO data.
  DATA read_only           type        abap_bool.
  DATA SELECT_VIS          TYPE   WDUI_VISIBILITY.


  FIELD-SYMBOLS: <fs_carrid> type table.


lr_data = wd_this->m_handler->get_range_table_of_sel_field( i_id = 'S_CARR_ID' ).
ASSIGN lr_data->* to <fs_carrid>.

*" navigate from <CONTEXT> to <RADIO_NODE2> via lead selection
  lo_nd_radio_node1 = wd_context->get_child_node( name = wd_this->wdctx_radio_node1 ).
*" call method get lead selection index to get index
  CALL METHOD lo_nd_radio_node1->get_lead_selection_index
    receiving
      index = lw_index.


  lo_el_radio_node2_1 = wd_context->get_element( ).

  If lw_index = 2.
* set field for selection
  wd_this->m_handler->upd_selection_field(
                                          i_id = 'S_CARR_ID'
                                          i_read_only = abap_false ).

  endif.

endmethod.

----------------------------------------------------------------------------------------------------------------

But Select options are still disables, even after i used method upd_selection_field. I also tried to use
set_attribute but keeps getting error as shown in attached screen shot. Please advise.


manigandan_d2
Explorer
0 Kudos

create a vaiable"Selection_VIs type Boolean" and map it ViewUIcontainer visible property of seletion option and Please use below logic in action method of radio button.

 

DATA lo_el_context TYPE REF TO if_wd_context_element.

  lo_el_context = wd_context->get_element( ).
  IF key = '01'.
    lo_el_context->set_attribute(
      name =  `SELECT_VIS`
      value = 'X' ).
  ELSE.
    lo_el_context->set_attribute(
    name =  `SELECT_VIS`
    value = ' ' ).
  ENDIF.

let me know if you requir more information.

Regards,

Mani

m_aravindan
Active Participant
0 Kudos

Hi,

         Have a look into this tutorial..

http://saptechnical.com/Tutorials/WebDynproABAP/Hide/Page1.htm

As said by saichand , use the visible property of the view container , to make it visible or none

with the selection of radio buttons.

Regards

Aravindan