Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

to compare whether a user has a role assigned and to perform an activity.

Hi Experts,

I have used the below code to get the roles assigned to a particular user.

I need to find whether my role Role:A is in the list.

If it is present in the list then i have to perform some activity like hidding some fileds from the view and displaying others.

IWDClientUser wdUser = WDClientUser.forceLoggedInClientUser();
		IUser user = wdUser.getSAPUser();
		String strRoleID = "", strRoleDesc = "";

		IRoleFactory iRoleFactory;
		iRoleFactory = UMFactory.getRoleFactory();

//		   Get All the Roles of the User
		Iterator iteratorRoles = user.getRoles(true);//prtRequest.getUser().getRoles(true);

//		   Loop through all the Roles
		while(iteratorRoles.hasNext())
		{
		strRoleID = iteratorRoles.next().toString();
		try 
		{
		strRoleDesc = iRoleFactory.getRole(strRoleID).getDescription();

String str = "ALSS"; 
		if((strRoleDesc).trim().equals(str))
		{
		wdContext.currentContextElement().setSecondCont(WDVisibility.VISIBLE);
		wdContext.currentContextElement().setDebug("1");


}
		else
		{

wdContext.currentContextElement().setSecondCont(WDVisibility.BLANK);

When i use this my code goes to the else part. And I have checked that the role ALSS is present in the list. Please advice where i am going wrong.

Points will be given for helpful answers.

Regards,

Sanjyoti.

Former Member
Former Member replied

hi !

pleasse refer to the following link

http://help.sap.com/saphelp_nw04/helpdata/en/f5/4dd9d47a200d46bd1c56062f49e10b/frameset.htm

thanks

vishal

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question