cancel
Showing results for 
Search instead for 
Did you mean: 

User Search Application to fetch data from UME

Former Member
0 Kudos

Dear All,

I have a requirement of creating a User Search Application that fetches data from UME. I went through the below link but I am confused in what project should I creat in NWDS.

http://wiki.sdn.sap.com/wiki/display/EP/Portal+Components+for+searching+Users+in+UME+(HTMLB,+Interna...)

Any inputs will be of great help.

Thank you,

Regards,

Disha.

Accepted Solutions (1)

Accepted Solutions (1)

Sreejith1
Contributor
0 Kudos

Hi Disha,

You can create Webdynpro or Portal Application (other java also possible).

Sample code(webdynpro) will look like this:

IUserFactory usrFact = UMFactory.getUserFactory();

IUserSearchFilter usrFilt = usrFact.getUserSearchFilter();

String usrPrefix = wdContext.currentContextElement().getSearchTerm();

usrFilt.setUniqueName(usrPrefix,ISearchAttribute.LIKE_OPERATOR,false);

IPublicUME_Comp.IAllUSersElement usrElement = null;

wdContext.nodeAllUSers().invalidate();

String usrName = null;

ISearchResult result = usrFact.searchUsers(usrFilt);

if (result.getState() == ISearchResult.SEARCH_RESULT_OK) {

     if(result.size()>0);

     while (result.hasNext()) {

     usrElement = wdContext.nodeAllUSers().createAllUSersElement();

     usrName = (String) result.next();

     usrName = usrName.substring(usrName.lastIndexOf(":") + 1,usrName.length());

     usrElement.setUsers(usrName);

     wdContext.nodeAllUSers().addElement(usrElement);

     }

}

You can modify the above an can use in Portal application also.

Regards,

Ram

former_member445255
Participant
0 Kudos

Hi Ram,

Could you please explain us little more details, means where we have to put the given sample code and component controler or view.

Thanks

Former Member
0 Kudos

You may use this code in a custom method either in component controller or view. Its better to be in component controller so that you may re-use the code if required.

Sreejith1
Contributor
0 Kudos

Hi Disha,

Let me explain.

we will do it in webdynpro Java. Create a local dc project and create a component.(hope you know this part)

You need all users after making a search.From this point you need 2 context variable.

1. for making search - take it as 'searchTerm'

2. for displaying the users. So the cardinality is 1:n (n number of users)

so you create a value node and make its cardinality 1:n and create a string attribute 'Users'

you can create this in component controller or in view. after making all things you can think about whats the difference in making this in view/contoller?

Next step

You need to create a GUI.one input box for search term and the out put in one table.

Using apply template option you can create two GUI elements

one input box (for 'searchTerm')

one table ( for 'Users')

and button (for execution)

For button, create one action and call above code in that method.

only this line may make you confused

IPublicUME_Comp.IAllUSersElement usrElement = null;

IPublic<Comp name>.I<node name>Element usrElement = null;

wdContext.nodeAllUSers().addElement(usrElement);

wdContext.node<node name>().addElement(usrElement);

So the flow will be like this.

You are taking the search term and executing the method. It make search and the result will put over the User attribute.

Still you are not able to follow,I can send you the more details.

But i will advice you to try it yourself and make you more confident.

If you blindly follow step by step document, your knowledge will not improve.

If you are not able to find the solution ask others and using that knowledge try to create things your self. It will make you capable to do things individually.

Let me know if anything

Regards,

Ram

Former Member
0 Kudos

Dear Ram,

Thank you so much for your help and guidance. I am very new to webdynpro and this is the 1st time creating a webdynpro application.

As per your above post I have created a Webdynpro application. I am getting stuck in creating the 2 context variables. Request you to guide with the detailed steps i.e what am I supposed to do and how, it will help me understand the procedure better.

Thank you,

Regards,

Disha.

Sreejith1
Contributor
0 Kudos

under > webdynpro Components, you can see your component.

under that one 'component controller' will be there. Double click that select context and create

attribute like above.

then double click your component.then u will get diagram view. there just drag a line from view to controller.Then it will show the attributes . select all.

Now the same context will be available in your view.

then do the view layout and  coding.

Still you find diff, let me know.

For some reference you can use this link:

http://scn.sap.com/docs/DOC-8661

Ram

Former Member
0 Kudos

Dear Ram,

Thank you very much. I could successfully run and deploy the Webdynpro application. But this application displays just the Unique Name even if I write:


"usrFilt.setDisplayName(usrPrefix,ISearchAttribute.LIKE_OPERATOR,false"

or

 

"usrFilt.setEmail(usrPrefix,ISearchAttribute.LIKE_OPERATOR,false"


Eventually I want to display a table of information of Users with all the information i.e FirstName, LastName, Email, etc. Could you plz suggest how to I add more columns in the table.

Will highly appreciate your help.

Note: I was getting error in the below line:
IPublicUserSearchAppComp.IAllUsersElement usrElement = null;


so I converted it as below:
IPrivateUserSearchAppCompView.IAllUsersElement usrElement = null; (This works)

Thank you,

Regards,
Disha.

Sreejith1
Contributor
0 Kudos

Hi Disha,

If you have userid, you can get any information from userFactory.

Just make one instance of user factory and there you will get all other attributes like

firast name, last name etc..... using  <userfactory>.get<property>;

eg: IUser user = userFact.getUser(userID);

              user.getFirstName();

also one more thing about below one:

>IPublicUserSearchAppComp.IAllUsersElement usrElement = null;

>IPrivateUserSearchAppCompView.IAllUsersElement usrElement = null; (This works)

the first one is component controller and second one is view.

I think you have written the method in view. thats why second one works.

If you write it in controller, the first one will work.

Regards,

Ram

Answers (1)

Answers (1)

amolgupta
Active Contributor
0 Kudos

hi Disha,

You may like to refer to the following document. 

http://scn.sap.com/docs/DOC-19552

This explains how to create a Portal user in the UME. The procedure and jar mentioned are relevant to your requirement.

Regards,

-Amol