Skip to Content
avatar image
Former Member

How to enable / disable my UI elements.

Hi,

I have 2 UI (Input field) in my layout ,both are set to disabled in properties.

Also i have a button called EDIT,so whenever i click this button during runtime , these inputfields has to get enabled.

How i can get this ?

Please help me.

Regards

Siva

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Oct 16, 2008 at 04:33 AM

    Hi Siva,

    Suman has given you the suggested way of achieving this functionality i.e, binding the "Enabled" property of the input field to an context attribute of type ABAP_BOOL & then manipulating its values in the buttons action handler. If however you are just trying to have a go at dynamic programming in WebDynpro ABAP then this is the way that you can do it. However please note that we are suggested not to follow this approach as it involves modifying the layout in a method other than WDDOMODIFYVIEW. This is a violation of the Web Dynpro Phase Model and is not recommended by SAP. This can lead to problems or inconsistencies down the road for which SAP will not be responsible. All dynamic manipulation must occur in the WDDOMODIFYVIEW.

    Regards,

    Uday

    1) Create 2 input fields in the layout with id's as I1 & I2.

    2) Create a button with an action (say by name "Enable") associated with it.

    3) Create 2 view level attributes as shown below:

    lr_i1 type ref to cl_wd_input_field
    lr_i2 type ref to cl_wd_input_field

    4) In WDDOMODIFYVIEW save the references of the input fields into the 2 above variables as shown below:

    METHOD wddomodifyview .
      check first_time = abap_true.
        wd_this->lr_i1 ?= view->get_element( id = 'I1' ).
        wd_this->lr_i2 ?= view->get_element( id = 'I2' ).
    ENDMETHOD.

    5) Finally the code to make the input fields as enabled on click of the button:

    method ONACTIONENABLE .
      wd_this->lr_i1->set_enabled( value = 'X' ).
      wd_this->lr_i2->set_enabled( value = 'X' ).
    endmethod.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Uday Gubbala

      Thanks Uday...thanks a lot,its working.. its bcos am a begginer,its difficult to understand.. but now i got it.. thanks a lot.. assigned points to all my saviours.. thanks ..

  • avatar image
    Former Member
    Oct 16, 2008 at 04:14 AM

    Hi siva,

    Create a context attribute enable of type abap_bool.

    populate this attribute in the eventhandler method of button with abap_true.

    bind this attribute to the visible property of your input field in the layout.

    thats all you will the input fields with enable.

    check this code.

    DATA lo_el_context TYPE REF TO if_wd_context_element.
      DATA ls_context TYPE wd_this->element_context.
      DATA lv_enable LIKE ls_context-enable.
    * get element via lead selection
      lo_el_context = wd_context->get_element(  ).
      
      lv_enable = abap_true.
      CALL METHOD LO_EL_CONTEXT->SET_ATTRIBUTE
        EXPORTING
          VALUE  = lv_enable
          NAME   = 'ENABLE'

    .

    Edited by: suman kumar chinnam on Oct 16, 2008 6:16 AM

    Edited by: suman kumar chinnam on Oct 16, 2008 6:28 AM

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 16, 2008 at 04:24 AM

    Hi,

    The enabled property takes the abap_bool type flag.

    So you define an abap_bool object calle dvisibility with default val = '-' and bind this with Enabled property of input field.

    And later on click of the button change it to 'X'.

    I hope it helps.

    Regards,

    Sumit Oberoi

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 16, 2008 at 07:32 AM

    hi,

    Its very simple!!!!!!! You can do the same this way also:

    1) Create a context attribute named "ENBL" type WDY_BOOLEAN (Do not check the read only property of context attribute).

    2) Now bind this context to ENABLE or READ ONLY property of your input box UI element.

    Initially the fields will be disabled or in read only mode when you try to run your application.

    3)On the action of push button write the following code:

    wd_context->set_attribute( name = 'ENBL' value = 'X' ).

    This will enable the input box ready for input.

    hope, this will help you.

    Thanks,

    Sumit

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Siva,

      the mistake is name change name to ENABLE instead of FIRST_NAME

      lr_node->set_attribute( EXPORTING name = 'FIRST_NAME'
      value = 'X' ).

      check this code and do in this way.

      DATA: lo_nd_person TYPE REF TO if_wd_context_node,
          lo_el_person TYPE REF TO if_wd_context_element,
         ls_person TYPE wd_this->element_person.
      * navigate from <CONTEXT> to <PERSON> via lead selection
        lo_nd_person = wd_context->get_child_node( name = wd_this->wdctx_person ).
      
      ls_person-enable = abap_true.
      CALL METHOD LO_ND_PERSON->SET_ATTRIBUTE
        EXPORTING
      *    INDEX  = USE_LEAD_SELECTION
          VALUE  = ls_person-enable
          NAME   = 'ENABLE'

      .

      Edited by: suman kumar chinnam on Oct 16, 2008 11:40 AM