cancel
Showing results for 
Search instead for 
Did you mean: 

Passing value from 1 view to another view using plugs

Former Member
0 Kudos

Dear Experts

I tried to pass a value from one view to another view using plugs i follwed the steps given in the Wiki

but in the second view in the articel it has been specified that i we have to get the value in the event handler handlefromsearch.

I cant understand this, if we get the value here how we will pass it to wddoinit method because in doinit only we can use this variable to show to do processing etc.

Kindly guide me how to get the value in doint method by using the plugs method.

Regards

Kumar

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

In Outbound Plug tab you can see Parameter field in second table, which is in first view. In that Parameter field you can create a Parameter(for example IV_EMP_ID with Associated type as PERNR_D) for this Outbound Plug.

then you should go to second view Inbound Plug Tab and go to corresponding Inbound Plug even handler method. In this even handler Inbound plug method just add same field earlier you added in Outbound plug tab as a importing parameter .

you can pass this value into outbound plug like below code.

wd_this->fire_to_output_plg(

iv_emp_id = '0000001' " pernr_d

).

Regards,

Vijay

Former Member
0 Kudos

Hi,

To pass data from one view to another, better create context in component controller data will move automatically

from one view.

Cheers,

Kris.

Former Member
0 Kudos

HI Experts,

Thank You for the replies.

But when i keep debugger it is not coming into handle method where im getting the parameter from first view.

i refered this [wiki|http://wiki.sdn.sap.com/wiki/display/WDABAP/Passingtableparameterfromoneviewtoanotherview+locally]

Kindly guide me in solving this issue.

Thank You

Kumar

Former Member
0 Kudos

Hi,

Declar your context in component controller, and do mapping in both views, then try you will get values.

Cheers,

Kris.

Former Member
0 Kudos

Hi,

If you wanna use parameters of the Plugs to pass the value between the views, it can be achieved by below steps.

1. Create the parameters in the outbound plug of the first view. In the outbound plugs tab, at the bottom you will find the place to declare the parameters.

2. while calling the plug, pass the value for the parameter like this. wd_this->fire_sal_plg( sal_det = ls_sal ).

3. In the 2nd view, in the handle method of the inbound plug, create the parameter with same type of which you have created in the outbound plug. Now this parameter will have the value which you passed from the first view.

Hope it helps.

Regards,

Prabhuraj

Former Member
0 Kudos

Hi Kissnas,

Im aware of passing a value or parameter through component controller but i want to pass the value through plugs.

Hi Prabhu,

im geting the variable in Handle event then how can i pass it with in hook methods ie if im passing a employee id 101 from view1 and i need to show the details of the employee 101 in second view for that i will send the value 101 from the first view to second view and in doinit or in modify view i will write query to retrive.

but in handle event how can i do this?

Regards,

Kumar

gill367
Active Contributor
0 Kudos

You can do the same in handler method wtever you are doing in wddoinit ..

whether its writing query or something elese.

if you want to pass it to the wddoinit method.

make an attribute for the view.

attirbute tab will be there. create an attribute say name empid type string.

then you can refer to it by using wd_this->empid.

it will be available as a global variable in all the methods of the view.

thanks

sarbjeet singh

Former Member
0 Kudos

Hi,

Just do the coding in Handler method as you wanted to do in DOINIT/DOMODIFY method. Just retrieve the data and bind it to the context node so that it will get displayed in the view.

Regards,

Prabhuraj

Former Member
0 Kudos

Hi Prabhuraj,

As the parameters are declared only in handlevent of the inbound plug, if i try to acess it in the DOINIT/DOMODIFY it is throwing me the error. Kindly help me solve this issue.

Regards

Kumar

Former Member
0 Kudos

HI,

To make the value passed from the plugs available to hook methods of the second view, create a view attribute of similar type and set the value to this attribute in the Handler..

Somthing like this

wd_this->my_attribute = value_plugs.

This can be then accessed in WDDOMODIFY view hook method..

Thanks,

aditya.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>Im aware of passing a value or parameter through component controller but i want to pass the value through plugs.

I'm curious why. Mapping via component controller is quite efficient. There is only one set of data stored and all mappings are done as data/object references. There really is little to no performance benefit to passing via plugs.

ashish_shah
Contributor
0 Kudos

Hi ,

There are three basic ways of passing data from one view to another.

1) Context Mapping -> the simplest way , only one memory location defined for that attribute, so also an efficient way

2) Data passing using Assistance class -> just another way , also an efficient way since only one memory location defined for assistance class attribute

3) Data passing using Plug parameters -> Not the best of ways , since every time you navigate a new temporary variable is created , so wastage of memory.

So as Thomas Suggested , use the first way , Context mapping.

Regards,

Ashish Shah

Former Member
0 Kudos

Hi,

You need to change your approach.

WDDOINIT is a hook method called by framework at only one time during the lifetime of the view.

Plug handlers are called whenever you navigate from outbound to inbound plug.

If your code absolutely need to execute on doinit method then do it on the wddomodifyview method checking the parameter first time.

Former Member
0 Kudos

HI learner,

You retrieve it in the handler and then you can store it in an attribute of your assist class or in your context depending on for what purpose you want to use it.

Regards,

Mathieu.