cancel
Showing results for 
Search instead for 
Did you mean: 

how to access the attributes from a method

Former Member
0 Kudos

Hi,

Thanks to all who replied to my previous thread. Please let me know how to access the attributes in method of component controller in the view.

Let Component_method be my method in component controller which contrains few attributes like this

method component_method.

data : node1 type ref to if_wd_context_node,

itab type standard type of mara.

endmethod.

I want to access the above attributes in method of view.

method view1.

wd_comp_controller->method_component( ).

-


????? how to access the data of the method_component?

endmethod.

Kindly help me out in the syntax.

Rgrds

Mahathi

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi

To access component controller's data, you need to have it in the method's signature (exporting/changing etc parameters). The other option is you can declare global attributes for each controller (in the component controller's attribute tab), which are accessible in the entire WD component.

Chitrali

Former Member
0 Kudos

Hi mahathi

You should define the parameters in the header, not in the body of the method:

You can define it as importing, exporting, changing or returning, as you need. For example, in SE80

-


Parameter Cl.declar. RefTo Opt Type ref

node1 importing X if_wd_context_node

itab exporting mara

-


method_component().

" code here...

endmethod.

and when you have to call the method,

wd_comp_controller->method_component(

EXPORTING node1 = nodelocal " not importing!!!

IMPORTING itab = itablocal " not exporting!!!

).

i think that it's this what you want, don't i?

uday_gubbala2
Active Contributor
0 Kudos

Hi Mahathi,

Its not possible to make use of the attributes which are declared inside a method from another view. The variables which you declare in a method are only visible within that particular method. If you want to have th concept of global attributes then you need to define the attributes in the "Attributes" tab of component controller. You also need to checkmark the "Public" checkbox beside the attribute. You can then make use of this attribute inside your view using the special attribute WD_COMP_CONTROLLER. Say suppose you have created an global attribute at component controller level by name GV_TEST of type I. (Also the Public checkbox is checked.) Then you can access this variable from within a view by saying as:

ex:   WD_COMP_CONTROLLER->gv_test = 1.

Any method that you create at component controller level is by default visible across all the views in the component. However for the attributes created at component controller level you additionally will have to set this "Public" flag to make them as available to other views.

Regards,

Uday

PS: If your questions are answered then do the needful by closing the threads. You need to close off all answered threads as per the rules of the forum.