SAP Tech Pro

SAP Technical Blog
Topprice Price Comparison

How to hide a UI element without context binding in Webdynpro

How to hide a UI element without context binding in Webdynpro

For eg - we want to hide the UI element TPC_OWNING_CTX.

How to hide a UI element without context binding ABAP Webdynpro

Please write this code in the webdynpro view - WDDOMODIFYVIEW 



  DATA lo_container TYPE REF TO cl_wd_uielement_container.
  DATA lt_children  TYPE cl_wd_uielement=>tt_uielement.
  DATA lo_element   TYPE REF TO cl_wd_uielement.
  DATA lv_id        TYPE string.

* You can add in condition first_time = 'X' unless its changed 

  IF first_time = abap_true.
    lo_container ?= view->get_root_element( ).

    lt_children = lo_container->get_children( ).

    LOOP AT lt_children INTO lo_element.
      lv_id = lo_element->get_id( ).
      IF lv_id = 'TPC_OWNING_CTX'.
        lo_element->set_visible( '01' ).
      ENDIF.
    ENDLOOP.
  ENDIF.

You can also hide a particulate UI element if you know the ID as shown below:


DATA lo_element   TYPE REF TO cl_wd_uielement.
lo_element ?= view->get_element( 'UI_ELEMENT_ID' ). 
IF lo_element IS BOUND.
	lo_element->set_visible( value = '01' ).
ENDIF.

Add comment

Before Buying, Compare Prices at Topprice.in

Topprice.in