cancel
Showing results for 
Search instead for 
Did you mean: 

Hide an UI Element with ABAP statements

Former Member
0 Kudos

Hi,

I want to enhance a standard web dynpro.

This standard web dynpro mincludes one UI element "Link to action".

Simplify I want to hide this link within an enhancement of method WDODOMODIFYVIEW.

Normally I`ve got a context attribute to which the visible proberty is binded --> so i simply have to change the context attribute at runtime.

No problems so far.

Problem now:

The UI element I want wo change with help of an enhancement is defined liek this:

No Binding at all set to proberty VISIBLE.

Question:

How can I hide this UI element within an enhancement of method WDODOMODIFYVIEW without any modification (I do not want to create a context element and bind proberty to that context).

Is there any possibility to change the proberty directly from visible to invisible without any context element?

If read about method set_attribute_proberty but I am not certain how to change the proberty for an UI element directly (without any context binding)

Any idea?

Thanks and best regards

Andreas

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Andreas,

     You can use the set_enabled method of cl_wd_ui_element to disable it. Below is sample code to achieve the same.

     DATA : l_obj1 TYPE REF TO cl_wd_uielement_container,

                l_obj2 TYPE REF TO cl_wd_uielement,

     l_obj1 = view->get_element ('ROOTELEMENTUICONTAINER').

     l_obj1->get_child( EXPORTING id = 'UI_ELEMENT_NAME'  IMPORTING the_child = l_obj2. ).

     l_obj2->set_enabled (space).

Hope this helps,

~Athreya

Answers (9)

Answers (9)

Former Member
0 Kudos

Problem solved, thanks to all.

Now I know the relevant classes and methods!

Former Member
0 Kudos

Hi Andreas,

Please go through this..

http://help.sap.com/saphelp_nw04s/helpdata/en/45/d44e0cdff073b1e10000000a11466f/content.htm

you can change code to set visible property..

CALL METHOD lr_elem->set_attribute_property

      EXPORTING

        attribute_name = 'ARRTIME' 

      property         = lr_elem->e_property-visible
        value          = l_restrict.

Cheers,

Kris.

bradp
Active Participant
0 Kudos

Hi Andreas,

You need to use a PRE or POST method exit for method WDDOMODIFYVIEW and add in the code below:

    DATA: lo_lta_free_desc TYPE REF TO cl_wd_link_to_action.

* Only run the first time the view loads
  IF first_time = abap_true.
   
* Get the specific UI element and downcast to link to action typ ui element
    lo_lta_free_desc ?= view->get_element( 'FREE_DESCRIPTION' ).

* Check username and set the visibility accordingly
    IF sy-uname = 'ABC'.
      lo_lta_free_desc->set_visible( cl_wd_link_to_action=>e_visible-visible ).
    ELSE.
      lo_lta_free_desc->set_visible( cl_wd_link_to_action=>e_visible-none ).
    ENDIF.

  ENDIF.

Hope that works for you.

Cheers,

Brad

mh97
Contributor
0 Kudos

Yes, here is some example code for two elements, a dropdown by key and a label ... you need to set the 'visible' property of the ui element to 0. First you need to get reference to ui element, which you can get from the View reference. The View reference is available in wddomodifyview.

  DATA:
    lo_approver_ddk TYPE REF TO cl_wd_dropdown_by_key,
    lo_approver_lbl TYPE REF TO cl_wd_label.

  lo_approver_ddk ?=

        view->get_element( 'APPROVERDROPDOWNBYKEY' ).
  lo_approver_lbl ?=

        view->get_element( 'APPROVERLABEL' ).

  lo_approver_ddk->set_visible( 0 ).
  lo_approver_lbl->set_visible( 0 ).

For 'link to action' element look up the correct class from the UI Element documentation (available in the layout editor in SE80).

Former Member
0 Kudos

Hi Andreas,

You can use the method UI_SET_VISIBLE of the class CL_FITV_WD_UTIL to hide the UI element during run time.

Just try the below mentioned code in the post-exit of WDDOMODIFYVIEW method.

cl_fitv_wd_util=>ui_set_visible( io_view = view iv_id = 'FREE_DESCRIPTION' iv_visible = abap_false ).

iv_id is the ID of the UI element you want to hide.

I have tried this and it has worked for me.

Regards,

Sanjeev Kotwal.

Former Member
0 Kudos

Andreas,

you will have to create an enhancement for the view ans in the layout you will be able to right click and delete the element you dont want and it would be removed from the screen . It would not delete it actually but just hide it but as per Enhancement it is considered to be deleted.

Phani

Former Member
0 Kudos

This message was moderated.

Former Member
0 Kudos

get refreence of ui element as shown by Athreya Hegde  you can use set_VISBL or SET_ENABLE method as per your need

Former Member
0 Kudos

Hi , I think you can remove the UI element using context menu as part of your enhancement.

Former Member
0 Kudos

Hi,

thanks a lot, but that is not exactly what I am looking for.

I do not want to remove the UI elment at all, I just want to hide it depending on some circumstances.

For example:

Enhancement WDODOMODIFYVIEW

IF sy-uname eq 'ABC'

hide UI Element FREE DESCRIPTION (invisible)

else.

keep standard behaviour

endif.

So I am looking for a method or something else to change the behaviour of an UI element directly at runtime but I do not want to create an attribut and change the binding of the UI, because that would mean creating a real modification.

Any other ideas?

Best regards

Andreas