cancel
Showing results for 
Search instead for 
Did you mean: 

dynamically change the attribute of an UI element created in design time

former_member224404
Active Participant
0 Kudos

Hi team,

I have created a group in a view in design time. Now in runtime I want to change the attribute e.g vgutter or design of the view programmatically . I don't know how to do that.

Please reply with a sample code.

Thanks,

Mainak

Accepted Solutions (0)

Answers (4)

Answers (4)

former_member215843
Active Participant
0 Kudos

Hi Mainak,

Some properties, like vGutter cannot be bound, because they are not intended to be changed often.

As Heidi suggested, you should change this via dynamic programming and this is explained in Thomas' blogs.

Ciao, Regina

Former Member
0 Kudos

HI Mainak,

You must have binded the Group UI element of your view to a node in the view's context.This has to done in WDDOMODIFY method the view.

The solution to your problem:

1: Add another attribute in your context Node. Please dnt give any Dict Type to the properties of your Node, because it would not take it, as the new attribute does not belong to that structure. Give The Dict type of this new attribute as String.

2: Bind your UI Element property to that context attribute. In your case the UI element property happens to be Group and its property as vGutter.

3: Now in any function Module you can read this attribute, change its value and set it back to the context.

Some Code example:

In my case the node happens to be 'Flights' and the newly added attribute as 'Variable'.

data:

Node_Flights type ref to If_Wd_Context_Node,

Elem_Flights type ref to If_Wd_Context_Element,

Stru_Flights type Wd_This->Element_Flights ,

Item_CARRID like Stru_Flights-CARRID.

  • navigate from <CONTEXT> to <FLIGHTS> via lead selection

Node_Flights = wd_Context->get_Child_Node( Name = wd_This->wdctx_Flights ).

  • @TODO handle not set lead selection

if ( Node_Flights is initial ).

endif.

  • get element via lead selection

Elem_Flights = Node_Flights->get_Element( ).

  • @TODO handle not set lead selection

if ( Elem_Flights is initial ).

endif.

  • alternative access via index

  • Elem_Flights = Node_Flights->get_Element( Index = 1 ).

  • @TODO handle non existant child

  • if ( Elem_Flights is initial ).

  • endif.

  • get single attribute

Elem_Flights->get_Attribute(

exporting

Name = `Variable`

importing

Value = Item_Variable ).

Item_Variable = 50.

Elem_Flights->set_Attribute(

Name = `Variable`

Value = Item_Variable ).

Hope This Helps.

Cheers!

Ashish

Former Member
0 Kudos

Hi,

see the weblogs by Thomas Szuecs on dynamic programming <a href="/people/thomas.szcs/blog/2005/12/28/dynamic-programming-in-web-dynpro-abap--introduction-and-part-i-understanding-ui-elements">one</a> and <a href="/people/thomas.szcs/blog/2006/01/03/dynamic-programming-in-web-dynpro-abap--part-ii-handling-viewelements

Regards, Heidi

Former Member
0 Kudos

Generally, you should bind those UI element properties to context attributes and change the values of these attributes. This can be done from any controller method.

Armin