cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamically controlling visibility of a field.

Former Member
0 Kudos

Hi Guys,

              I am controlling the visibility of fields using context attribute bind to the visibility property of the respective field.

I am using a Boolean type ABAP_TRUE and ABAP_FALSE for the binding context attribute.

but still the fields are still visible even when it has value ABAP_FALSE.

Wondering how to debug the code in FPM ?

Cheers

Sam

Accepted Solutions (0)

Answers (3)

Answers (3)

amy_king
Active Contributor
0 Kudos

Hi Sam,

Define your context attribute which will control visibility as type WDY_BOOLEAN. Then bind the visibility property of the UI element to this context attribute. In your code, you should be able to continue to use ABAP_TRUE and ABAP_FALSE when setting the value of the context attribute.

  lo_nd_visible = wd_context->get_child_node( name = wd_this->wdctx_visible ).
  lo_el_visible = lo_nd_visible->get_element( ).

  lo_el_visible->set_attribute(
    name =  `ATTRIBUTE_NAME`
    value = abap_false ).

Be sure that the code which toggles visibility true or false is really executing. You can do this by setting an external breakpoint in the code which sets visibility to false, then run your application. If you do not hit the breakpoint, then your code is not executing and you may need to set the visibility elsewhere in the process flow.

Cheers,

Amy

Former Member
0 Kudos

Hi,

If ur doing it in fpm..

U can set the visibilty in get_data method .

Loop at lt_field_usage Into ls-filed_usage.

  If ls_field_usage-name = <field_name>

      ls_field_usage-visibility = abap_false.

  ENDIF

      append ls_field_usage to ct_field_usage.

     ENDLOOP.

ev_field_usage_changed = abap_true.

Former Member
0 Kudos

Hi Guys,

              I tried WDY_BOOLEAN data type as well as WDUI_VISIBILITY as a context attribute data type.

But its not working.

The context attribute bind to Visibility property of the field.

Its bit funny.. its not responding..!!

Thanks

Sam

Former Member
0 Kudos

Hi,

      I used WDY_BOOLEAN and WDUI_VISIBILITY as well.

But its not working..!

Thanks

Sam

Former Member
0 Kudos

Were you able to debug and check that the attribute had proper value?

Former Member
0 Kudos

Hi Sam,

Try like this,bind your filed to attribute with WDUI_VISIBILITY data type.

lo_nd_visible = wd_context->get_child_node( name = wd_this->wdctx_visible ).

  lo_el_visible = lo_nd_visible->get_element( ).

  lo_el_visible->set_attribute(

    name =  `FIELD_ID`

    value = '01'  )."Hide'"

lo_el_visible->set_attribute( 

    name =  `FIELD_ID`

    value = '02'  )."Show

Thanks,

Lavanya.

former_member199125
Active Contributor
0 Kudos

Sam,

in general for visibility we will use WDUI_VISIBILITY attribute with values 01( hide) & 02( visible).

Regards

Srinivas

Former Member
0 Kudos

Yes.. I did the same.. 01 - Hide, 02 - Visible

and the bind to the visible property of the context.

Still not making any impact. I should try to update the context itself, as Lavanya advised.

Thanks

Sam

Former Member
0 Kudos

Hi,

The visible property has two possible values, None - 00 and Visible - 01.

You can set the value using type WDUI_VISIBILITY which should theoretically be used for handling visibility.

Former Member
0 Kudos

For controlling visibility I would use one variable of type WDR_BOOLEAN and bind with visibility property and set it X or space depending on condition when to make visible or not visible.