Enable/Disable & Show/Hide UI Elements during runtime in Web Dynpro for ABAP

...Previous

21.  Double Click on SHOW_HIDE event, add a Importing Parameter as INDEX type ‘I’

and write the below piece of code in ONACTIONSHOW_HIDE

Method ONACTIONSHOW_HIDE.
  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_node1_1 TYPE ref to if_wd_context_element. 
  
* 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 get lead selection index to get index 
  CALL METHOD lo_nd_radio_node1->get_lead_selection_index
    receiving
      index  = lw_index.      
  lo_el_radio_node1_1 = wd_context->get_element(  ).  
  If lw_index = 1.  
* call method set attribute property and pass value as 'X' to show 
  call method lo_el_radio_node1_1->set_attribute_property
    exporting
      attribute_name = 'FIRST_NAME_1'
      property       = 1
      value          = 'X'.
* call method set attribute property and pass value as 'X' to show 
  call method lo_el_radio_node1_1->set_attribute_property
    exporting
      attribute_name = 'LAST_NAME_1'
      property       = 1
      value          = 'X'.
  Else.
* call method set attribute property and pass value as SPACE to HIDE
  call method lo_el_radio_node1_1->set_attribute_property
    exporting
      attribute_name = 'FIRST_NAME_1'
      property       = 1
      value          = space.
* call method set attribute property and pass value as SPACE to HIDE
  call method lo_el_radio_node1_1->set_attribute_property
    exporting
      attribute_name = 'LAST_NAME_1'
      property       = 1
      value          = space.    
  Endif.                               
endmethod.

22.  Now again go back to the Layout tab of your main view, click on RADIO_GROUP2 and create an event as ENABLE_DISABLE and add a Importing Parameter as INDEX type ‘I’ and write the below piece of code in ONACTIONSHOW_HIDE

Method ONACTIONENABLE_DISABLE.
  DATA lo_nd_radio_node2 TYPE REF TO if_wd_context_node.
  DATA lo_el_radio_node2 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. 
  
* navigate from <CONTEXT> to <RADIO_NODE2> via lead selection
  lo_nd_radio_node2 = wd_context->get_child_node( name = wd_this->wdctx_radio_node2 ).
* call method get lead selection index to get index 
  CALL METHOD lo_nd_radio_node2->get_lead_selection_index
    receiving
      index  = lw_index.      
  lo_el_radio_node2_1 = wd_context->get_element(  ).  
  If lw_index = 1.  
* call method set attribute property and pass value as 'X' to ENABLE 
  call method lo_el_radio_node2_1->set_attribute_property
    exporting
      attribute_name = 'FIRST_NAME_2'
      property       = 4
      value          = 'X'.
* call method set attribute property and pass value as 'X' to ENABLE 
  call method lo_el_radio_node2_1->set_attribute_property
    exporting
      attribute_name = 'LAST_NAME_2'
      property       = 4
      value          = 'X'.      
  ELSE. 
* call method set attribute property and pass value as SPACE to DISABLE
  call method lo_el_radio_node2_1->set_attribute_property
    exporting
      attribute_name = 'FIRST_NAME_2'
      property       = 4
      value          = space.
* call method set attribute property and pass value as SPACE to DISABLE
  call method lo_el_radio_node2_1->set_attribute_property
    exporting
      attribute_name = 'LAST_NAME_2'
      property       = 4
      value          = space.  
   Endif.                               
Endmethod.

23.  Now create a Web Dynpro Application as shown below:  

 

    

24.  Now SAVE and Activate your Application. Test your Application after creating a web dynpro application. 

 

25.Final Output:- 

 

Click on “HIDE” radio-button.

Click on “DISABLE” radio-button. 

 

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image