cancel
Showing results for 
Search instead for 
Did you mean: 

Pass logged-in userid to RFC

Former Member
0 Kudos

I'm using the Adaptive RFC model.

The WD tutorials show how to connect an input field to an RFC input variable. This is not what I need to do. I need to pass the logged-in userid to the RFC to get all employee information about the logged-in user.

How do I pass the logged-in user value to the RFC prior to execution? What is the syntax, and where do I need to put the code in the "implementation" (right before the execute)?

Thanks,

Kevin

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Kevin,

You don't have to map the RFC to the UI elements.

Simply use the following code to get the logged in userID.


// get the currently logged in user  

IWDClientUser wdUser = WDClientUser.getCurrentUser();

//get the com.sap.security.api.Iuser; It is null in case wdUser represents an anonymous user

IUser user = wdUser.getSAPUser();

//check whether the user is anonymous

if (user != null)
{
     //access logon ID by iterating through the IUserAccount array
				               
     IUserAccount[] acct = user.getUserAccounts();		
     if(acct[0] != null)
     {
         String strUserid = acct[0].getLogonUid();
         //pass the value obtained from the portal to value attribute
				     
     }
}

Set the userID to suitable the RFC attribute like this:


         wdContext.current<<i>RFCNode</i>>().set<<i>Attribute</i>>( strUserid));	

and execute the RFC to get the desired result.

Bala

Answers (0)