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

...Previous

15.  Now copy the element FIRST_NAME_LABEL by right clicking on it and select Copy Element, then right click on ROOTUIELEMENTCONTAINER and click Insert Copied Element as shown below: 

 

 

16.  Repeat the same with input field FIRST_NAME then with label  LAST_NAME_LABEL and input field LAST_NAME.

       Change the layout of FIRST_NAME_LABEL_CP as MatrixHeadData and select labelFor as FIRST_NAME_CP, do the same with LAST_NAME_LABEL _CP change layout to MatrixHeadData and select LabelFor as LAST_NAME_CP. 

 

17.  Change the binding for value of input field FIRST_NAME_CP with context element FIRST_NAME_2 and bind property enabled with FIRST_NAME_2 and select the radio button ‘Bind to the Property of the Selected Attribute Property’ as ‘Enabled’, also select and change property visible to ‘Visible’  as shown below: 

 

18. Repeat the same with LAST_NAME_CP, bind value with LAST_NAME_2, property enabled with LAST_NAME_2 and select the radio button ‘Bind to the Property of the Selected Attribute Property’ as ‘Enabled’, also select and change property visible to ‘Visible’.    

 

19.  Now go to the Methods tab and double click on initialization method that is WDDOINIT: 

Now write the below piece of code in it: 

Method WDDOINIT.
*"--------------------------------------------------------------------*
* Code to display text as 'Show' and 'Hide' in application.           *
*"--------------------------------------------------------------------*
  DATA lo_nd_radio_node1 TYPE REF TO if_wd_context_node.
  DATA ls_radio_node1    TYPE wd_this->element_radio_node1.
  DATA t_radio_node1     TYPE if_main_view=>elements_radio_node1.
  ls_radio_node1 = 'Show'.
  append ls_radio_node1 to t_radio_node1.
  ls_radio_node1 = 'Hide'.
  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.
*"--------------------------------------------------------------------*
*" Code to display text as 'Show' and 'Hide' in application.          * 
*"--------------------------------------------------------------------*
  DATA lo_nd_radio_node2 TYPE REF TO if_wd_context_node.
  DATA ls_radio_node2    TYPE wd_this->element_radio_node2.
  
  DATA t_radio_node2     TYPE if_main_view=>elements_radio_node2.
  ls_radio_node2 = 'Enable'.
  append ls_radio_node2 to t_radio_node2.
  ls_radio_node2 = 'Disable'.
  append ls_radio_node2 to t_radio_node2.  
  
* 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 bind table and pass the table t_radio_node1 to display text
  CALL METHOD lo_nd_radio_node2->bind_table
    EXPORTING
      new_items            = t_radio_node2.
Endmethod.

20.  Now go back to the Layout tab of your main view, click on RADIO_GROUP1 and create an event as SHOW_HIDE as shown below: 

Click here to continue....

 

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