cancel
Showing results for 
Search instead for 
Did you mean: 

Set a value of an attribute to View from reference IF_WD_COMPONENT

Former Member
0 Kudos

Hi,

Can we set a value of an attribute to View context from reference IF_WD_COMPONENT?

WD application calls a class with improting parameter 'IF_WD_COMPONENT' to pass its own reference. The class needs to set value of an attribute to View context from this reference IF_WD_COMPONENT.

Could you please tell me how i can do that? or is it NOT possible?

...Naddy

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello Naddy,

When we create a view three attributes are being provided to the developer by webdynpro framework.

wd_this, wd_context, wd_comp_controller.

wd_this would be used to access the attributes defined at view level. and you could use this attribute of any controller to access attributes at that controller level.

you could access the attribute by statement wd_this->attribute name.

You would need wd_context of type if_wd_context_node to access the attribute defined at context level.

Regards

Anurag Chopra

Former Member
0 Kudos

Hi Anurag,

I need to set the value of an attribute of view in the class method who has WD component as reference of IF_WD_COMPONENT.

or am i understood incorrectly?

...Naddy

Former Member
0 Kudos

Hi Naddy,

My mistake, I misunderstood you.

But you would also need to use the above information.

you have to do this step by step.

1) you need to check if there is multiple component usgae or not. As you have to identify of which component you have that view where you need to change the attribute value.

2) Once you have the info, you would need to access the interface of the component controller.

3) Then you would have to reach to the interface of the view controller.

4) as told earlier.

In se24, you could refer the interface and access the appropriate method.

Regards

Anurag Chopra

Former Member
0 Kudos

Hi Anurag,

WD Component not using any additional component. I've enhanced standard WD Component with view and window. Now i need to set a value of an attribute in the enhanced view context from a class which has reference of WD Component as IF_WD_COMPONENT.

...Naddy

Former Member
0 Kudos

Hello,

Please have a look at the following code:

method TEST_METHOD.
  DATA context TYPE REF TO IF_WD_CONTEXT.
  DATA node TYPE REF TO IF_WD_CONTEXT_NODE.
  DATA ele TYPE REF TO IF_WD_CONTEXT_ELEMENT.

  context = component->get_context( ).
  node = context->root_node->get_child_node( 'NODE_FLIGHT' ).
  ele = node->get_element( ).

  ele->set_attribute( EXPORTING name = 'CARRID'
                                value = 'AA' ).


endmethod.

This method takes a parameter component of type IF_WD_COMPONENT. And it sets the attribute CARRID of node NODE_FLIGHT.

THis works! But i am not sure why you want to set the attributes of context node in a class passing the component reference. Instead you can call a method of class to get the value to be set and in the component controller itself you can set the value of the attribute right!

Hope this helps!

Regards,

Srilatha

Former Member
0 Kudos

Hi Srilatha,

We are creating simple application with complex logic. Thanks for your code. it deserves 10 points.

...Naddy

Answers (1)

Answers (1)

Madhu2004
Active Contributor
0 Kudos

Hi,

Without mapping the node form component controller to view,We can not set the value for view's context attribute from component controller.However the converse is possible .

Only way is to solve your issue enhance the compnent controller's context and map the same node in view controller.

Regards,

Madhu.