Skip to Content
avatar image
Former Member

Disable & Enabled Buttons

hi all,

I would like to disable a button B1 or enable it depend on some status in my application.

How i can disable or enable the button in WDA?

BR,

Ali

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

4 Answers

  • Best Answer
    avatar image
    Former Member
    Mar 31, 2009 at 06:07 AM

    Hi Ali,

    In your WDDOMODIFYVIEW method try the following:

    DATA lr_button              TYPE REF TO cl_wd_button.
    
     lr_button             ?= view->get_element( '<Your Button ID Name>' ).

    Based on some condition you can now set the enabled property of your button here.

    lr_button->set_enabled( exporting  value = 'X' or SPACE ).

    Hope this is helpful.

    Regards,

    Abhinav

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 31, 2009 at 05:55 AM

    Hi ALi,

    Bind the 'enabled' property of the button with context attribute of type char1.

    When you want to enable it set the value to 'X' or ' ' (space) when you want to disable it.

    Regards,

    Saket.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Follow the steps:

      1) Click on button in the layout

      2) Goto Properties (Button) on right side pane

      3) 4th prop is 'enabled'. Click on the button (3 rd column i.e. Binding) next to 'enabled' property.

      4) This will open the popup of context attributes.

      5) Map it with desired attribute (previously created of type char1)

      Regards,

      Saket.

  • avatar image
    Former Member
    Mar 31, 2009 at 06:16 AM

    Hi,

    Create a context attribute of typemWDY_BOOLEAN and bind the enabled property of the button to this.

    In the MODIFYVIEW method..

    DATA:
        lr_btn  type ref to cl_wd_button,
        lv_btn_app_enable type wdy_boolean,                   " Enable
        lr_view_ele type ref to if_wd_view_element.
    
      CALL METHOD VIEW->GET_ELEMENT
        EXPORTING
          ID      = 'B1'        "Button Id
        RECEIVING
          ELEMENT = lr_view_ele.
    
    ***Gettig the button object reference for REVIEW button
      lr_btn ?= lr_view_ele.
    
    --------------Put your condition here-------------
    ***Enable and Disable  button
            lv_btn_app_enable = abap_false.                    "Disable
            CALL METHOD wd_context->SET_ATTRIBUTE
              EXPORTING
                VALUE = lv_btn_app_enable
                NAME  = `BTN_APP_ENABLE`      "Context attribute
    
            CALL METHOD lr_btn->SET_ENABLED
              EXPORTING
                VALUE = lv_btn_app_enable.

    Regards,

    Lekha.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 31, 2009 at 06:23 AM

    Thanks all

    My Problem Solved.

    Add comment
    10|10000 characters needed characters exceeded