on 11-06-2012 12:47 PM
Hi All
How to Retrieve the all the UME users into webdynpro java and bind them to drop down by key.
Based on the selection of the user in drop down record should be displayed in the table .
how to write the logic for the above requirement .
Regards
Deepika
Hi,
You can refer to this http://scn.sap.com/thread/2020907 on getting the user's list.
Create a DropDownByKey, Bind a Node say Values to it. Then add this code in wdInit method.
At the end, instead of printing on to the screen, add it to the Node createdabove.
IUserFactory uFactory = UMFactory.getUserFactory();
ISearchResult AllUserIds = uFactory.getUniqueIDs();
while (AllUserIds.hasNext()) {
String UserID = (String) AllUserIds.next();
IUser sapUser = uFactory.getUser(UserID );
if (sapUser.getUserAccounts()[0] != null) {
wdComponentAPI.getMessageManager().reportSuccess("Logon UID: " + sapUser.getUserAccounts()[0].getLogonUid());
}
//Add it to Values Node
}
Then you can create a event for dropdown select and perform the action you want.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ravi
Thanks for your quick reply .
But here I am getting success message with all User id's displayed.
But I want to add this Userid's to drop down by key .Here is the following code what i had implemented in the DoInt method.
IUserFactory uFactory = UMFactory.getUserFactory();
ISearchResult AllUserIds = null;
try {
AllUserIds = uFactory.getUniqueIDs();
} catch (UMException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
while (AllUserIds.hasNext()) {
String UserID = (String) AllUserIds.next();
IUser sapUser = null;
try {
sapUser = uFactory.getUser(UserID);
//String Uid = sapUser.getUserAccounts()[0].getLogonUid();
} catch (UMException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
if (sapUser.getUserAccounts()[0] != null) {
wdComponentAPI.getMessageManager().reportSuccess("Logon UID: " + sapUser.getUserAccounts()[0].getLogonUid());
wdContext.nodeNode().currentNodeElement().setAttribute(sapUser.getUserAccounts()[0].getLogonUid());
wdContext.nodeNode().bind()
}
} catch (UMException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
But it is gvg Java Null Pointer exception.
what the code i have written for capturing the Id's and binding to the code is gvg error.
please correct correct me this code .
Thanks & Regards
Deepika
Hi Deepika,
Please initialize the node first and then create a node element within the While loop.
Once you create the node element, you can then set the node attribute with the Logon Id value.
In the Final step, you have to add the node element created in the above step to the node.
Please remember these steps need to be performed within the While loop mentioned in your code.
Let me know in case you require any other details.
P.S. - Please set the node's cardinality to 0..n if it's not that.
Regards,
Anurag
Hi Deepika,
To have the printed userid in the drop down list, please follow these steps
1) Created a Node say Users and attribute within that as UserId of type string.
2) Set the Cardinality 0..n.
3) Bind the UserId attribute to text property of the DropDownByIndex UI element in the screen.
4) Relace the code which you have written above for setting node after printing values with the below one.
IUsersElement users=wdContext.nodeUsers().createAndAddUserElement();
users.add(sapUser.getUserAccounts()[0].getLogonUid());
and
5) comment the code of printing the userdetails to the screen.
Mark it is answered if it works fine.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.