cancel
Showing results for 
Search instead for 
Did you mean: 

Read User Roles From Portal into ABAP Report

Former Member
0 Kudos

I have written a report which takes users and specific roles as the input. Eg, userID :12345 and role/profile :SAP_ALL, SAP_ADMIN..etc in a table. and gives back if the user 12345 has SAP_ALL or not.

Now I have used RFCs to fetch all the roles for the user from different SAP systems which i further compare , to get the above.

What I am unable to do is fetch the portal roles .

PROBLEM : The portal roles also exist in the central system, but might not be always consistent since they get manually updated in the central system. Hence I want to directly fetch the data from the JAVA Portal.

WHAT I KNOW : I need to write a JAVA class in NW developer studio which will take the user as the input and give me all the roles/profiles for the same user as output.

How do I further pass the values to and from the Java class to my ABAP report?

I know that I need to use the UME in some way to have this work for me. But since i do not expertize in java I need guidance/steps as to how to proceed.

Regards

Trishna

Edited by: Trishna Udupa on Sep 11, 2011 3:00 PM

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Dear Trishna,

for that you will need to develop your own RFC to process that information and send the roles back to your R3.

Kind Regards

/Ricardo Quintas

Former Member
0 Kudos

Dear Trishna,

here's a code snippet from a development I once did.

This JAVA code was used to create a Sitemap for the user.

Ther part I'm sending you here was where the code extracted the roles for specific user.

Hope it helps you.

Don't bother with the classes Utilities and RecursiveTree.

They were part of the code and you won't need them for your problem.


	/**
		 * > we first get USER information, namely the NavigationNodes
		 * > we then create an instance of object RecursiveTree and transfer the
		 *   NavigationNodes found. They will be used to build the Sitemap.
		 */
		private void getRoles() {
			String user = utilities.request.getUser().getUniqueName();
			java.util.Locale userLocale = utilities.request.getLocale();
			utilities.writeLogMessage(
				"Method getRoles started for USER: " + user);
			com.sap.security.api.IRoleFactory roleFactory =
				UMFactory.getRoleFactory();
			IUserFactory userFactory = UMFactory.getUserFactory();
			try {
				IUser logedInUser = userFactory.getUserByLogonID(user);
				Iterator roles = logedInUser.getRoles(true);
				for (Iterator groups = logedInUser.getParentGroups(true);
					groups.hasNext();
					) {
					String groupName = (String) groups.next();
					groupName = groupName.toUpperCase();
					if (groupName.indexOf(utilities.propertyGroupName) != -1)
						utilities.beanMain.setCopyToClipBoard(true);
				}

				INavigationService navigationService =
					(INavigationService) PortalRuntime
						.getRuntimeResources()
						.getService(
						"com.sap.portal.navigation.service.navigation");
				Hashtable environmentTable = new Hashtable();
				com.sapportals.portal.prt.session.IUserContext userContext =
					utilities.request.getUser();
				environmentTable.put("NavigationPrincipal", userContext);
				environmentTable.put("User", user);
				com.sapportals.portal.navigation.NavigationNodes rootNodes =
					navigationService.getInitialNodes(environmentTable);
				RecursiveTree tree =
					new RecursiveTree(rootNodes, 0, userLocale);
				utilities.beanMain.setResultList(tree.getResultList());
			} catch (UMException e1) {
				utilities.processErrorMessage(
					"Method getRoles UMException: " + e1.getMessage());
			} catch (NamingException e2) {
				utilities.processErrorMessage(
					"Method getRoles NamingException: " + e2.getMessage());
			} catch (Exception e3) {
				utilities.processErrorMessage(
					"Method getRoles Exception: " + e3.getMessage());
			}
			utilities.writeLogMessage("Method getRoles OK for USER: " + user);
		}
	}
}

Kindest Regards

/Ricardo Quintas

Former Member
0 Kudos

Hi Ricardo,

Thanks for the piece of code. But what I am still wondering is how to get the roles back into my ABAP report? Is there a RFC enabled function module which will do that for me? or any connection that I have to create?

Regards,

Trishna

Former Member
0 Kudos

Hi Trishna,

You can create a java class in NWDS that will give you all the portal roles of a particular user and create a webservice out of it by deploying it on the Java engine. After you test your webservice, you can consume the same from an ABAP report. I have never tried this , but i guess it should work.

Regards

Mayank