cancel
Showing results for 
Search instead for 
Did you mean: 

Passing parameters dynamically to an RFC from WebDynpro

Former Member
0 Kudos

Hi,

I have a Web Dynpro application which will call an R/3 RFC that returns a PDF file.

1) Is it possible to pass parameters dynamically (For eg userid of the person who has logged onto the portal) from webdynpro to a RFC? If yes, how?

Thanks in advance.

Jayesh

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Jayesh,

I saw you have made an RFC that returns a PDF file from back end R/3. Can you give me an exmaple as to how to do that in the RFC. I think once you are returning it from the BAPI I can bind it to a binary variable in WDP and use it. Please correct me if i am wrong

Regards

Jay Kapadia

Former Member
0 Kudos

Hi Jayesh,

you have to have the parameter in the BAPI signature. So when you create the model in Web Dynpro a corresponding model attribute will also get created in your model node structure. After that just create context mapping between this model attribute and the component context's attribute and then from component context to view contxt. So whenever you populate some data in the view context attribute it will be populated in the corresponding attribute of the model. And when you call the execute method of the model proxy this paramter value will be automatically passed to the RFC.

Regards,

Shubhadip

Former Member
0 Kudos

Thanks for your reply, Shubhadip. The user id that I want to pass is not something that will be entered by the user.

My question is how do we get the userid of the person who has logged in (some method or code) and where do we write that code? If you could give me that it would be extremely helpful.

Thanks in advance.

Jayesh

Former Member
0 Kudos

Hi Jayesh,

for catching the current user you can use the following code block..

try{

IWDClientUser user = WDClientUser.getCurrentUser();

if(user.isAnonymousUser()){

//User is anonymous .. do something...

}else{

//user is authenticated..do something

}

}catch(WDUMException e){

//do something...

}

Hope it helps!!!

Shubhadip

Former Member
0 Kudos

Hi,

If I understand correctly, is that you want to know which user entered in to the SAPlogon pad R3 system. in your webdynpro code you are intending to get that user id and password right is this the one you are looking for if it is so confirm me

i can help you

RK

Former Member
0 Kudos

Just to add..

you can write this code block in any method of the view or component for eg wdDoInit. From this IWDClientUser object you can fetch details about the current user.

Regards,

Shubhadip

Former Member
0 Kudos

Thanks a lot Shubhadip.

RK:

What I want is

1)capture the userid of the user who has logged into the portal and

2)how to pass the userid, to the RFC in code.

Thanks and Regards,

Jayesh

Former Member
0 Kudos

Hi,

if you get the user details from this IWDClientUser object, then you can set the user details values (such as user name or something) in the view context attributes and can pass them to the RFC by context mapping as I said in the first message.

If you get your problems solved let us know in detail and dont forget to reward points )

regards,

Shubhadip

Former Member
0 Kudos

Hi Shubhadip,

I added your code to wdDoInit, but I am getting the following errors:

1)IWDClientUser cannot be resolved or is not a type

2)WDClientUser cannot be resolved

3)WDUMException cannot be resolved or is not a type

Please help.

Thanks and Regards,

Jayesh

Former Member
0 Kudos

Hi Jayesh,

hope you are using NWDS. Please add the following import statements in your code

import com.sap.tc.webdynpro.services.sal.um.api.IWDClientUser;

import com.sap.tc.webdynpro.services.sal.um.api.WDClientUser;

import com.sap.tc.webdynpro.services.sal.um.api.WDUMException;

hope it solves your problem.

Regards,

Shubhadip

Former Member
0 Kudos

Hi Shubhadip,

Thanks, the import statements work fine.

How do I actually pass the values (userid) to the execute method (mentioned in your initial reply) of the model proxy? It would be extremelely helpful if you could give me the code snippet.

Thanks and Regards,

Jayesh

Former Member
0 Kudos

Hi Jayesh,

use the following tutorial to see how to pass parameter values to R/3 functions.

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/creating a web dynpro application accessing abap functions.pdf

regards,

Shubhadip