简体   繁体   English

如何获取视图的所有ui元素? (Web Dynpro ABAP)

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

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? 有没有办法获取所有视图元素,以便我可以遍历它们并使标签动态不可见?

Each view controller contains the method WDDOMODIFYVIEW with an initially empty implementation. 每个视图控制器都包含方法WDDOMODIFYVIEW,该方法最初是一个空的实现。 Inside this method you have access to the whole UI element hierarcy and should be able to retrieve references to both the label and the input field and hide the lable in case the input field is hidden. 在此方法内,您可以访问整个UI元素层次结构,并且应该能够检索对标签和输入字段的引用,并在输入字段被隐藏的情况下隐藏标签。

Here's some example action handler code which finds the label MYLABEL inside a container and hides it. 这是一些示例动作处理程序代码,该代码在容器内找到标签MYLABEL并将其隐藏。 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.

First, write a second program that will be responsible for calling your program using the SUBMIT ABAP instruction with the EXPORTING LIST TO MEMORY addition. 首先,编写第二个程序,该程序将使用SUBMIT ABAP指令和EXPORTING LIST TO MEMORY附加项来调用您的程序。

When you run this caller program it will call your program using the SUBIT, but instead of generating output on screen, system will send the output to system memory. 当您运行此调用程序时,它将使用SUBIT调用您的程序,但系统不会将输出发送到屏幕上,而是将输出发送到系统内存。

Later, in webdynpro or in any other program, you can call ABAP function LIST_FROM_MEMORY to retrieve your program's earlier output to an internal table. 以后,在webdynpro或任何其他程序中,您可以调用ABAP函数LIST_FROM_MEMORY将程序的早期输出检索到内部表中。

Cheers! 干杯!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM