How do i get all ui elements of a view? (Web Dynpro ABAP)

vikdb picture vikdb · Dec 17, 2012 · Viewed 17.4k times · Source

I want to make the labels of an input field invisible when the input field is invisible. I cant bind it to the same context because they are build dynamically.

Is there a way to get all view elements so i can loop over them and make the label invisible dynamically?

Answer

René picture René · Dec 18, 2012

Here's some example action handler code which finds the label MYLABEL inside a container and hides it. It doesn't completely cover your use case, but I think it will get you started.

data view type ref to cl_wdr_view.
view ?= wd_this->wd_get_api( ).
data container type ref to cl_wd_uielement_container.
container ?= view->root_element.
data children type cl_wd_uielement=>tt_uielement.
children = container->get_children( ).
data element type ref to cl_wd_uielement.
loop at children into element.
  data id type string.
  id = element->get_id( ).
  if id = `MYLABEL`.
    element->set_visible( `01` ).
  endif.
endloop.