cancel
Showing results for 
Search instead for 
Did you mean: 

GetR3UserName Problem

Former Member
0 Kudos

Hi everyone, i need your help, i have search in all thread and still i can't find the answer. I know how to find portal user using WDClientUser.getCurrentUser() but i can't find the R3 user. My code like this

String sessionStatus = null;

IWDClientUser user = null;

String userID = null;

// Get User ID from ESS / Portal SSO

try {

user = WDClientUser.getCurrentUser();

} catch (WDUMException e1) {

logger.traceThrowableT( Severity.ERROR, "GetSapUserId()", "Error", e1 );

isError = true;

}

if ( user == null ) {

isError = true;

}

if ( !isError ) {

Map userMap = null;

IUser iUser = user.getSAPUser();

IUserMapping userMapping = UMFactory.getUserMapping();

if ( iUser != null ) {

try {

//userID = userMapping.getR3UserName()

userID = userMapping.getR3UserName(iUser,null,false);

//userID = userMapping.getR3UserName(iUser, "UIDPW", userMap, true); --> deperecated ???

try {

// This code is intended to avoid unmapped user (e.g. using SSO)

int userIDInt = Integer.parseInt( userID );

} catch (NumberFormatException e) {

isError = true;

}

} catch (UMException e2) {

logger.traceThrowableT( Severity.ERROR, "GetSapUserId()", "Error", e2 );

isError = true;

}

In this code i have try

1. userID = userMapping.getR3UserName(iUser, "UIDPW", userMap, true);

2. userID = userMapping.getR3UserName(iUser, "SAPLOGONUSERID", userMap, true);

3. the last i using getR3UserName that using system landscape object = null

but all fail, still i'm only get portal user. Anyone can help me ? Thanks

Regards,

Satria

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Dear Satria,

i try to write a WD-Java that uses the portal usermapping service as well.

I have added all the jar's to my WD-Project but running it i get an ClassNotFoundError for IUserMapping on:

IUserMapping userMapping = UMFactory.getUserMapping();

Itried a lot with SharingReference and so on, can you hepl me to get my application running ?

Thanks,

best regards André

Former Member
0 Kudos

Dear André

I have solved my problem without this class. I used BAPI function module USER_NAME_GET. You can get output user name from this function module. So basically i call this RFC Function Module from my WD-Java. Just try it.

former_member182374
Active Contributor
0 Kudos

Hi satria budiman,

The 2nd parameter of the method should be system name and not logon method.

So you should write something like this:

userID = userMapping.getR3UserName(iUser, "SAP_R3", userMap, true);

'SAP_R3' is the system name in the portal.

This code will work but since this method is deprecated it is better to use:

getR3UserName(IUser user, ISystemLandscapeObject system, boolean bGenerateId)

See Maksim's example here:

Regards,

Omri

Former Member
0 Kudos

Hi Omri, thank you for your answer but

I have code like this :

userID = userMapping.getR3UserName(iUser, "SAP_R3_HUMANRESOURCES", userMap, true);

but still not work. For Maksim example i confused what parameter that must i through for e.getSystemByUniqueKey(......) and e.getSystemByAlias(....); How i get this parameter correctly ? Another problem is that wrappers.size() == 0 in my code, why this happen?

Right now, i have success get this R3 User Name, but not using Webdynpro method but using RFC Function Module USER_NAME_GET. I have test it with some user and success but i don't know if this is correct/best solution, anyone have use it before ?

I'm interested in this topic but i can't find step by step tutorial that clearly explain this, I suggest there should be someone explain this user authentication and other thing...

Thank you

Regards,

Satria

former_member182374
Active Contributor
0 Kudos

Hi,

Did you define system in your portal? (see link and snapshot)

http://help.sap.com/saphelp_ep60sp2/helpdata/en/1f/bddf3d48b05d5ae10000000a11405a/content.htm

http://img119.imageshack.us/img119/7714/portalsystemscy1.jpg ('SAP_R3' it's a name I chose it can be anything...)

The method's name is a confusing 'getR3UserName' can be used for getting R3, BW, CRM or any SAP R3 'like' system (it depends on the system alias that is provided).

Systems are used for creating transaction, iviews etc...

If you don't have portal system objects and all you need is the R3 user name than I guess using the RFC is good enough.

Omri