Skip to Content
author's profile photo Former Member
Former Member

hide or show uielements

Hello,

can I hide or show uielements depending on a customertable. In this custumer table

the uielements have an additional columns as status for display or hide.

Regards

ertas

Add a comment
10|10000 characters needed characters exceeded

Related questions

9 Answers

  • Best Answer
    Posted on May 22, 2009 at 02:14 PM

    Hi,

    Bind the UI elements visibility property with the attribute of type wdui_visibility

    Read that visibility coloum of table and on the basis of their status set the visibility of UI elements visible or In-Visible.

    To make it visible set attribute as 02

    To make it In-visible set attribute as 01

    I hope it helps.

    Regards,

    Rohit

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 25, 2009 at 06:57 AM

    Hello,

    I get this error message:

    Node MAIN.1.VISIBILITY does not contain any elements

    There are two ddic tables

    ZPERSCONFIG contains two fields =fieldname and visiblilty (yes or no)

    ZPERS coantains data about person

    I have create a context node VISIBILITY with cardinality 0:1 with a attribute VISIBLE of type CHAR1.

    Populate this context node attribute with 'X' OR space based your table entry.

    method WDDOINIT .
      data wa type ZPERSCONFIG.
      data lr_node type ref to if_wd_context_node.
    
      select * from ZPERSCONFIG into table wd_this->TCONF.
      lr_node =  WD_CONTEXT->get_child_node( name = 'VISIBILITY' ).
    
    
      LOOP AT wd_this->TCONF INTO wa.
        IF wa-SICHTBAR = 'X'.
          lr_node->SET_ATTRIBUTE( EXPORTING NAME = 'VISIBLE' VALUE =  abap_true ).
        else.
          lr_node->SET_ATTRIBUTE( EXPORTING NAME = 'VISIBLE' VALUE =  abap_false ).
        endif.
      ENDLOOP.
    
      DATA: lt_kteile TYPE if_main=>elements_pers,
                  wa_kteile TYPE if_main=>element_pers,
                  lv TYPE REF TO if_wd_context_node.
    
      lv = wd_context->get_child_node( name = 'PERS' ).
      lv->bind_table( new_items = lt_kteile ).
    endmethod.

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi,

      Try Using the Your code in the following way.

      method WDDOINIT .
        data wa type ZPERSCONFIG.
          DATA lo_nd_visibility TYPE REF TO if_wd_context_node.
        DATA lo_el_visibility TYPE REF TO if_wd_context_element.
        DATA ls_visibility TYPE wd_this->element_visibility.
        DATA lv_visible TYPE wd_this->element_visibility-visible.
       
        select * from ZPERSCONFIG into table wd_this->TCONF.
        * navigate from <CONTEXT> to <VISIBILITY> via lead selection
        lo_nd_visibility = wd_context->get_child_node( name = wd_this->wdctx_visibility ).
      
      * get element via lead selection
        lo_el_visibility = lo_nd_visibility->get_element( ).
       
        LOOP AT wd_this->TCONF INTO wa.
          IF wa-SICHTBAR = 'X'.
      
      * set single attribute
        lo_el_visibility->set_attribute(
          name =  `VISIBLE`
          value = abap_true ).
           
          else.
           * set single attribute
        lo_el_visibility->set_attribute(
          name =  `VISIBLE`
          value = abap_false ).
          endif.
        ENDLOOP.
       
        DATA: lt_kteile TYPE if_main=>elements_pers,
                    wa_kteile TYPE if_main=>element_pers,
                    lv TYPE REF TO if_wd_context_node.
       
        lv = wd_context->get_child_node( name = 'PERS' ).
        lv->bind_table( new_items = lt_kteile ).
      endmethod.

      I hope it helps.

      Regards,

      Rohit

  • author's profile photo Former Member
    Former Member
    Posted on May 25, 2009 at 09:05 AM

    dear rohit I dont get the error message that was the solution for dunping.

    But the next problem is I get all the elements displayed.

    e.g. is field name invisible it should not be displayed. What can the reason be for that ?

    Maybe is abap_false not the right command for NONE

    lo_el_visibility->set_attribute(
        name =  `VISIBLE`
        value = abap_false ).
        endif.

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Ertas,

      Ur welcome! The coding would come to something like this... Suppose ZPERSCONFIG has a field by name fieldname which holds the name of the ui element that you want to control then you have a code similar to the one shown below. [ Am sorry if it does contain any syntax/typing mistakes as its just 30 minutes before I get to run home! 😊 ]

      Regards,

      Uday

      LOOP AT wd_this->TCONF INTO wa.
         case wa-fieldname.
      	when 'FIELD1'.
       IF wa-SICHTBAR = 'X'.
       * set single attribute
        lo_el_visibility->set_attribute(
          name =  `ATTR1`
          value = abap_true ).
           else.
      * set single attribute
        lo_el_visibility->set_attribute(
          name =  `ATTR1`
          value = abap_false ).
          endif.
      when 'FIELD2'.
      IF wa-SICHTBAR = 'X'.
      * set single attribute
        lo_el_visibility->set_attribute(
          name =  `ATTR2`
          value = abap_true ).
           else.
      * set single attribute
        lo_el_visibility->set_attribute(
          name =  `ATTR2`
          value = abap_false ).
          endif.
         endcase.
      ENDLOOP.

  • author's profile photo Former Member
    Former Member
    Posted on May 22, 2009 at 02:15 PM

    Do you have an code example for me ?

    Kindly Regards

    ertas

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 22, 2009 at 02:23 PM

    Create a context node VISIBILITY with cardinality 0:1 with a attribute VISIBLE of type CHAR1.

    populate this context node attribute with 'X' OR space based your table entry.

    now bind the VISIBLE attribute to the UI element for which you want to make it hide or visible.

    now populate the VISIBLE with 'X' or space by calling the method of the node

    VISIBILITY->SET_ATTRIBUTE ( EXPORTING NAME = 'VISIBILE' VALUE = VISIBLE ).

    Regards,

    Anil kumar G

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 25, 2009 at 08:47 AM

    hi I have tried it this the result

    this is not initial

    lo_nd_visibility = wd_context->get_child_node( name = wd_this->wdctx_visibility ).

    this initial in the debugger

    lo_el_visibility = lo_nd_visibility->get_element( ).

    right here the error message

    Access via 'NULL' object reference not possible.

    * set single attribute
      lo_el_visibility->set_attribute(
        name =  `VISIBLE`
        value = abap_true ).

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 22, 2009 at 02:07 PM

    Hi Ertas,

    Yes , you can hide or show UI elements based an any attribute value or a database table field value.

    Basically you can set any attribute value by binding the property of that particular to any context node that you have created in your view. Obviously that particular context node you must be fetching the data from one of the database table you want. so in runtime based on the value in the field the visibility varies.

    the property VISIBLE of the UI element you need to bound.

    Regards,

    Anil kumar G

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 25, 2009 at 07:52 AM

    hi Uday I have changed but I am getting still the same error message

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 25, 2009 at 12:14 PM

    uday thousand thanks.

    I will check it up. I have rigth now a telco. If I am ready I give you a feedback

    Regards

    ertas

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.