cancel
Showing results for 
Search instead for 
Did you mean: 

disable a button in the view

Former Member
0 Kudos

hi

i am creating an abap WD and i want that a certion button in the view i created will be disable or inVISIBLE?

how can i do that?

i have searched the forum and i only got information for java WD

thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Bind the visibility property with the context attribute of the type WDUI_VISIBILITY.

Now in ur code based on the condition u can set the attribute value.

Set the value as '01' for visible and '02' for invisible.

DATA lo_el_context TYPE REF TO if_wd_context_element.
  DATA ls_context TYPE wd_this->element_context.
  DATA lv_ca_atttt LIKE ls_context-ca_atttt.
* get element via lead selection
  lo_el_context = wd_context->get_element(  ).

* get single attribute
  lo_el_context->set_attribute(
    EXPORTING
      name =  `CA_ATTTT`
      value = '01' ).

Answers (6)

Answers (6)

Former Member
0 Kudos

hi ,

u can disable /enable as well make visible /invisible ur UI elements

b) for making ur UI enable/disable , bind it with the context attribute of type wdy_boolean

using the set_attribute method

i) 'X'' to make the UI enable

ii) ' ' to make UI disable

Read context attribute using CODE WIZARD AND set it to 'X' using the method to make it enable

u can do it for idisable as well


// read attribute 
  DATA lo_nd_cn_visibility TYPE REF TO if_wd_context_node.
    DATA lo_el_cn_visibility TYPE REF TO if_wd_context_element.
    DATA ls_cn_visibility TYPE wd_this->element_cn_visibility.
    DATA lv_ca_visible LIKE ls_cn_visibility-ca_visible.
*   navigate from <CONTEXT> to <CN_VISIBILITY> via lead selection
    lo_nd_cn_visibility = wd_context->get_child_node( name = wd_this->wdctx_cn_visibility ).

*   @TODO handle not set lead selection
    IF lo_nd_cn_visibility IS INITIAL.
    ENDIF.

*   get element via lead selection
    lo_el_cn_visibility = lo_nd_cn_visibility->get_element(  ).


// make UI enable
*   set single attribute
    lo_el_cn_visibility->set_attribute(
      EXPORTING
        name =  `CA_VISIBLE`
      IMPORTING
        value = 'X').

regards,

amit

Former Member
0 Kudos

hi ,

u can disable /enable as well make visible /invisible ur UI elements

a) for making ur UI visible /invisible , bind it with the context attribute of type wdui_visibility

using the set_attribute method

i) '01' to make the UI invisible

ii) '02' to make UI visible

Read context attribute using CODE WIZARD AND set it to '02' using the method to make it visible

u can do it for invisibility as well


// read attribute 
  DATA lo_nd_cn_visibility TYPE REF TO if_wd_context_node.
    DATA lo_el_cn_visibility TYPE REF TO if_wd_context_element.
    DATA ls_cn_visibility TYPE wd_this->element_cn_visibility.
    DATA lv_ca_visible LIKE ls_cn_visibility-ca_visible.
*   navigate from <CONTEXT> to <CN_VISIBILITY> via lead selection
    lo_nd_cn_visibility = wd_context->get_child_node( name = wd_this->wdctx_cn_visibility ).

*   @TODO handle not set lead selection
    IF lo_nd_cn_visibility IS INITIAL.
    ENDIF.

*   get element via lead selection
    lo_el_cn_visibility = lo_nd_cn_visibility->get_element(  ).


// make UI visible
*   set single attribute
    lo_el_cn_visibility->set_attribute(
      EXPORTING
        name =  `CA_VISIBLE`
      IMPORTING
        value = '02').

u can do it like this way as well :

wd_context->set_attribute( name = '<attribute name>' value = if_wdl_core=>visibility_visible )." to make it visible.

wd_context->set_attribute( name = '<attribute name>' value = if_wdl_core=>visibility_none ). "to make it invisible

Former Member
0 Kudos

hi,

There are two things : Visible/Invisible and Enable/Disable.

For making your button visible/invisible , Create a context Attribute of type wdui_visibility.

Set its Values : 01 , for making Invisible.

02 , for making Visible.

For making your button enable/disable, Create a context Attribute of type wdy_boolean.

Set its Values : 'X', for making Enable.

' ' , for making Diable.

I hope it helps.

Former Member
0 Kudos

Hi,

for ENABLED nature -

Create a context attribute ENABLED as wdy_boolean

Bind the enabled proeperty of that Inout field to this attribute

IF wd_comp_controller->gv_read_only EQ 'X'.

lv_enabled = abap_false. "Disable

else.

lv_enabled = abap_true. "Enable

ENDIF.

wd_context->set_attribute

exporting

value = lv_enabled

name = 'ENABLED'

Regards,

Lekha.

former_member40425
Contributor
0 Kudos

Hi,

Create a attribute of type wdy_boolean and bind it with the enable property of Button..

To enable set it as 'X'

To Disable set it as ''.

Regards,

Rohit

Chaitanya_Priya
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi ,

To make a button visible or invisible create an attribute in the context and bind it the VISIBLE property of the button

to make it enable or disabled bind to ENABLED property of the input field.

According to criteria make it abap_true or abap_false.

you enable or disable in the following way:

DATA lo_nd_user_view TYPE REF TO if_wd_context_node.

DATA lo_el_user_view TYPE REF TO if_wd_context_element.

DATA ls_user_view TYPE wd_this->element_user_view.

lo_nd_user_view = wd_context->get_child_node( name = wd_this->wdctx_user_view ).

lo_el_user_view = lo_nd_user_view->get_element( ).

lo_el_user_view->set_attribute(

EXPORTING

name = `SAVE_CANCEL_ENABLE`

value = abap_false ).

Regards,

Priya