Skip to Content
Author's profile photo Former Member

Dynamically Setting the “Enabled” Property of a Webdynpro ABAP UI element.

This document will walk you through :

The concept of Enabling/Disabling a web dynpro UI-Element using the UI-element property “Enabled”.


Assumption :

    1. You have created a web dynpro application .

    2. You have created the UI elements “Field1” in the view , which you have to enable/disable .


Procedure :

   Step 1 : Create a Attribute in the context of the view with type “WDY_BOOLEAN” lets say i have created “field1_enabled”.

   Step 2 : Bind the property “Enabled” of the Field1 with “field1_enabled” (context attribute created in step 1 ).

   Step 3 : Now based on your requirement , place the below code in the appropriate method for enabling the Field1 .


                 DATA lv_field1_enable TYPE wd_this->element_context-field1_enabled.


                 lv_field1_enable = abap_true.            ” Enable field1


                 name = `field1_enabled`

                 value = lv_field1_enable ).

Step 3 :  Same way place the below code in the appropriate method for disabling the field1

                DATA lv_field1_enable TYPE wd_this->element_context-field1_enabled.

                lv_field_enable1 = abap_false.          ” Disable  field1


                name = `field1_enabled`

                value = lv_field1_enable ).


Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Hi the exact Workable code is here:

      Suppose on the Basis of Radio button group by index you have to Enable the particular UI elements(For radion button1) and Disable the Particular set of Elements(For radion button2).

      Create A RadiobuttonGroupbyIndex  and an action for "Event onselect" property of Radio buttonGroupbyindex let us say Enable _Disable. Write the below code under it.

      Create a node "UI_PARAMETER" in component controller under which create an Attribute  " MYTC_ENABLE_DISABLE" type "WDY_BOOLEAN". you can put the its DEFAULT property value 'X' Enable or '  ' space Disable. Drag the node UI_PARAMETER to View controller from componentcontroller. Go to the View layout where all the UI element is placed and mapp there Visible Property to attribute MYTC_ENABLE_DISABLE. All the UI elements in layout should be mapped which are supposed to be Effected

        Method Enable _Disable.

        DATA lo_nd_radio_node  TYPE REF TO if_wd_context_node.
        DATA lw_index            TYPE I.
      * navigate from <CONTEXT> to <RADIO_NODE> via lead selection
        lo_nd_radio_node = wd_context->get_child_node( name = wd_this->wdctx_radio_node ).
      * call method get lead selection index to get index
        CALL METHOD lo_nd_radio_node->get_lead_selection_index
            index  = lw_index.

        DATA lo_nd_ui_parameter TYPE REF TO if_wd_context_node.
        DATA lo_el_ui_parameter TYPE REF TO if_wd_context_element.

      * navigate from <CONTEXT> to <UI_PARAMETER> via lead selection
        lo_nd_ui_parameter = wd_context->get_child_node( name = wd_this->wdctx_ui_parameter ).

      * get element via lead selection
        lo_el_ui_parameter = lo_nd_ui_parameter->get_element( ).

      If lw_index = 1.
      * set single attribute to Enable
          name =  `MYTC_ENABLE_DISABLE`
          value = 'X' ).
      * set single attribute to Disable
          name =  `MYTC_ENABLE_DISABLE`
          value = ' ' ).

      ENDMETHOD."Enable _Disable

      Another way you can use below code to make them invisible :

      Lets say we have a table, Container Element, Button, & text view UI element on View layout their Ids on property Layout screen are TABLE_ID, View_container_ID and TXT_View_ID respectively, 

      DATA: lo_ref_tab TYPE REF TO cl_wd_table,       

                 lo_sel_opt TYPE REF TO cl_wd_view_container_uielement,        

                 lo_ref_but  TYPE REF TO cl_wd_button,        

                 lo_ref_YEAR_TXT1 TYPE REF TO CL_WD_TEXT_VIEW.    


      view TYPE REF TO cl_wdr_view.       

      view ?= wd_this->wd_get_api( ).


      lo_sel_opt      ?= view->get_element( 'View_container_ID' ). 

      lo_ref_but      ?= view->get_element( 'Button_ID' ). 

      lo_ref_tab      ?= view->get_element( 'TABLE_ID' ). 

      lo_ref_YEAR_TXT1 ?= view->get_element( 'TXT_View_ID' ). 


      lo_sel_opt->set_visible( 0 ). 

      lo_ref_but->set_visible( 0 ). 

      lo_ref_tab->set_visible( 0 ). 

      lo_ref_YEAR_TXT1->set_visible( 0 ).

      Author's profile photo Ronaldo Aparecido
      Ronaldo Aparecido

      Bem útil.