cancel
Showing results for 
Search instead for 
Did you mean: 

How to hide input field dynamically

Former Member
0 Kudos

Hi Expert,

I am trying to hide some input field from the view under certain conditions. Here is my code.

data: lr_input type ref to cl_wd_input_field.

if not stru_prod1-objek1 is initial.

lr_input ?= view->get_element( 'DESC1_1' ).

lr_input->set_visible( visibility = 'visible' ).

endif.

Here is the error message:

Formal parameter "VISIBILITY" does not exist. exist.

Can anyone tell me what wrong with my code?

Thanks,

ATANG

Accepted Solutions (1)

Accepted Solutions (1)

raja_thangamani
Active Contributor
0 Kudos

Welcome to SDN.

You can hide with below code:

lr_input->set_visible( CL_WD_UIELEMENT=>e_visible-NONE ).

Raja T

Former Member
0 Kudos

Hi Raja,

Thank you for the answer. It works.

Andy

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Andy,

Make use of This example which is used to hide an input field

DATA:

name_ip TYPE REF TO cl_wd_input_field.

name_ip ?= view->get_element( 'NAME').

" NAME is the name of input field in my view

CALL METHOD name_ip->set_visible

EXPORTING

value = abap_false

.

Regards

Sarath

Former Member
0 Kudos

Hi Sarath,

Here is the error message when call method is used in my abap code.

"ABAP-FALSE" is not type-compatible with formal parameter "VALUE".

Here is my code:

data: lr_dropdown type ref to cl_wd_dropdown_by_key.

lr_dropdown ?= view->get_element( 'OBJEK1' ).

CALL METHOD lr_dropdown->set_visible

EXPORTING

value = abap_false.

Thanks

Former Member
0 Kudos

Hi Andy,

Another way of doing this is the following:

Define a context attribute (or node of cardinality 0..1 with a context attribute) say INPUT_VIS. In the layout, for the property of the UI element visible, bind the context attribute INPUT_VIS.

Now based on your condition, set INPUT_VIS = 'X' (to view) or INPUT_VIS = ' '(to hide) as a value to the context attribute.

Hope this helps,

Regards,

Wenonah

Former Member
0 Kudos

Hi Venonah,

Thanks for the info but I don't get it. Can you provide some code for reference?

Thanks

Andy