cancel
Showing results for 
Search instead for 
Did you mean: 

How to call another view controller's method from a view controller?

Former Member
0 Kudos

Hello All,

I have a Main view in which i have a method ONACTIONGET_DATA.

How can I call this method from another view (VIEW1) in the same Webdynpro component.

I tried to understand the link below,But didnt able to call this method, Pls help.

http://scn.sap.com/thread/1787380

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello.

Create a new method in the component controller that shares those two views, and call it on method ONACTIONGET_DATA of Main view and at VIEW1 too.

Another option is to create the method in the Assistance Class of the Web Dynpro Component, and call it using the attribute WD_ASSIST of both views.

Regards,

Pablo.

Answers (2)

Answers (2)

rajeshkothamasu
Active Participant
0 Kudos

Hi Venkat,

     Create method in component controller. You can call that method in any view.

     call method using WD_COMP_CONTROLLER->"u r Method Name".

Thanks,

Raju

former_member185241
Active Participant
0 Kudos

Hey Ramanuja,

First go to Property of view1 there you have to click on used controller ( add view controller2 of the same component )

Now go to any method of View1, here using Code wizard you can call method of view2

Please let me know if you have any problem .

Thanks

Abhi

Former Member
0 Kudos

Hello Abhishek,

Thanks for the reply

As you suggested i went to my view VIEW1 -( in this view i want to access MAIN views method)

in the properties tab of the VIEW1  i have clicked on create controller usage button and selected

MAIN view/controller.

Now I went to the method of VIEW1 and in code wizard, I have selected method call in current controller

radio buttion and through F4 selected main view, then i got the object reference of main view as below

DATA LO_WND_MAIN TYPE REF TO IG_WND_MAIN.
LO_WND_MAIN = WD_THIS->GET_WND_MAIN_CTR( ).

But now if i say

CALL METHOD LO_WND_MAIN->ONACTIONGET_DATA( ). it says this method is unknown...

am i doing something wrong?


Former Member
0 Kudos

Hello,

At properties tab you have added the controller usage of the window controller where your MAIN view is embebed, not the view controller. I think that adding the controller of a view to another view is impossible. So you should try what i wrote on my previous answer, create a method in the component controller with the code of the method ONACTIONGET_DATA, and call it in both views.

Component Controller is added by default in properties tab of the view.

Regards,

Pablo.

former_member185241
Active Participant
0 Kudos

Hey

follow the suggestion by Pablo,

For this create same method in component controller and in any view of the same component you can call that method using reference variable wd_comp_controller

Signature is wd_comp_controller->"METHOD_NAME"

Thanks

Abhi