cancel
Showing results for 
Search instead for 
Did you mean: 

retrieve portal user

Former Member
0 Kudos

Hi,

can somebody help me. I want at starting of a WD application. That it retreives the portal user as in input of the bapi. Is there a tutorial or can somebody explain me what code i need to use or ahat i need to do

Regards

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

use the follwowing code,

String loginUser="";

IWDClientUser wdUser = WDClientUser.getCurrentUser();

IUser user = wdUser.getSAPUser();

if(user != null)

{

IUserAccount acct[] = user.getUserAccounts();

if(acct[0] != null)

{

loginUser = acct[0].getLogonUid();

}

}

add the follwing import statements,

import com.sap.security.api.IUser;

import com.sap.security.api.IUserAccount;

Former Member
0 Kudos

do i need to make vallue attributes?

Former Member
0 Kudos

Hi,

You have to the give the userid to the input of BAPI.If you using Custom controller you have to create the VAluenode and Attribute, And set this user id to the required attribute

Regards

Saravanan K

Former Member
0 Kudos

Hi,

Do you want to pass that logged in user details as an input to the BAPI? Then you don't need any value attributes. Retrieve that user name as suggested by others and set it to the BAPI input object.

Regards,

Satyajit.

Former Member
0 Kudos

I want to test first if the code is working. so I want to show the user in a table and i am using a custom controler. how should the code look lik then? what do i need to do

Former Member
0 Kudos

Hi,

In that case you will need to create a value attribute and bind it to a table column. Then retrieve the user name as suggested and set it to the context through this value attribute.

If you want to execute the retrieval code in your custom controller, then create another attribute in custom controller's context and map this to the view's context.

Regards,

Satyajit.

Former Member
0 Kudos

how does it look like in code...don't exactly understand what you mean

Former Member
0 Kudos

hi,

Create one value node in the context and add one value attribute to that node.

Bind the value node to the dataSource property of the table.

and also bind the value attribute to the text property of the tableCellEditor of correspoding column.

After execution of the bapi, get the portal username from the Bapi's output node and store it into a String variable (ex: userName). Then set the value to the value attribute.

like, wdContext.current<Tablenode>Element.set<TableAttribute>(userName);

Former Member
0 Kudos

Hi,

Let's say that you are doing the username retrieval part in the custom controller. So create a value attribute say, UserName in the custom controller's context. Also create a value attribute of the same name in the view controller's context under the value node that is boind to the datasource property of the table and map the custom controller attribute to the view controller's attribute. The view context might look like:

-Root

--TableDataNode

---UserName

---... (other nodes)

---...

....

Once you have fetched the user name in the custom controller, use a code like:


wdContext.currentContextElement().setUserName(userNameStr);

Now in your view, create a table column to show the user name. Insert a textview as the cell editor and bind the

text property to, TableData.UserName.

Regards,

Satyajit.

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Have a look at this thread

Regards,

Saravanan K

vijayakhanna_raman
Active Contributor
0 Kudos

Hi,

Check this

Regards,

Vijayakhanna Raman

sridhar_k2
Active Contributor
0 Kudos

Hi,

To Retrive Loged-In user from Portal use below Code.


IWDClientUser clientUser = WDClientUser.getLoggedInClientUser();
String user = "";
if (clientUser != null) {
  IUser iUser = clientUser.getSAPUser();
  if (iUser != null) {
  try {
   IUserAccount[] acct = iUser.getUserAccounts();
   if (acct[0] != null) {
    user = acct[0].getLogonUid();
   }
}catch (UMException umex) {
}
}
}
return user;

Regards,

Sridhar