cancel
Showing results for 
Search instead for 
Did you mean: 

Visibility of Field

Former Member
0 Kudos

Hello All.

I have a screen with two labels and input fields.

Depending upon the button the user clicks I should be able to make any one of the two fields visible to the user.

How could I achieve this?

Warm Regards,

SampathKumar G

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Thank You all.

Former Member
0 Kudos

Hello Ashish.

I tried using the code which You have provided.

But it shows an error that gv_item is not defined in data statement.

I tried using lv_item too.

For both of these syntax it shows an error.

Can you please help me in this regard.

Warm Regards and Thanks,

SampathKumar.

Former Member
0 Kudos

Hi,

Create an attribute 'VISIBLE' type boolean. Bind this attribute to the visible property of the uielement.

Now on your action method for button, pass abap_false/abap_true to make it hide/visible based on your condition.

Data: l_elem type ref to if_wd_context_node.

l_elem = wd_context->get_element
l_elem->set_attribute( exporting name = 'VISIBLE' value = abap_true ) " makes the uielement visible

pass abap_false to hide the same.

Regards,

Radhika.

former_member230839
Participant
0 Kudos

Hi Sampath,

Create a context node with a attribute names for example 'VISIBLE' and bind this attribute to the UI element that you want to make visible or hide. now you can set the attribute of this node wherver the logic that you want. So the correspoding visibility varies based on the logic.

Regards,

Anil kumar G

Former Member
0 Kudos

Hi Anil,

Do the following steps:

- create a stand alone attribute "visibility" under the root node.

- Bind this attribute to the UI element property "Enabled" and 'visibility"

Now based on the selection you can change the visibility property.

Use the following code:

DATA lo_el_context TYPE REF TO if_wd_context_element.

DATA ls_context TYPE wd_this->element_context.

DATA lv_visible LIKE ls_context-visible.

  • get element via lead selection

lo_el_context = wd_context->get_element( ).

if wd_comp_controller->gv_item eq abap_true.

lv_visible = abap_true.

else.

lv_visible = abap_false.

endif.

  • get single attribute

lo_el_context->set_attribute(

EXPORTING

name = `VISIBLE`

value = lv_visible ).

DATA lo_el_context TYPE REF TO if_wd_context_element.

DATA ls_context TYPE wd_this->element_context.

DATA lv_visible LIKE ls_context-visible.

  • get element via lead selection

lo_el_context = wd_context->get_element( ).

if wd_comp_controller->gv_item eq abap_true.

lv_visible = abap_true.

else.

lv_visible = abap_false.

endif.

  • get single attribute

lo_el_context->set_attribute(

EXPORTING

name = `VISIBLE`

value = lv_visible ).

Hope this helps.

Best Regards,

Ashish.