cancel
Showing results for 
Search instead for 
Did you mean: 

Sending User Id Dynamically

Former Member
0 Kudos

Hi,

I am using Adaptive RFC call for fetching data and displaying in a table based on user id in custom component controller's wdDoInit()method i wite the following code.

public void wdDoInit()

{

//@@begin wdDoInit()

System.err.println("With in init");

Zbapi_Employee_Bank_Details_Input input=new Zbapi_Employee_Bank_Details_Input();

wdContext.nodeZbapi_Employee_Bank_Details_Input().bind(input);

System.err.println("With in init user Id is"+WDClientUser.getLoggedInClientUser().getSAPUser().getUniqueName());

try{

input.setUserid(WDClientUser.getLoggedInClientUser().getSAPUser().getUniqueName());

wdContext.currentZbapi_Employee_Bank_Details_InputElement().modelObject().execute();

wdContext.nodeBankdetail().invalidate();

}

catch(Exception e){}

//@@end

}

System.err.println printing user id correctly.But when i am passing this user id I got ArrayIndexOutofboundException .Below code line is creating error

input.setUserid(WDClientUser.getLoggedInClientUser().getSAPUser().getUniqueName());

So how to resolve this problem

Thanks & Regards

muna

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Mukesh and Lohit,

My problem is not solved.

I already implement this code

String userid=WDClientUser.getLoggedInClientUser().getSAPUser().getUniqueName().toString();

input.setUserid(userid);

and later i did for avoiding blank space and using valueOf() method like below code

String userId=String.valueOf(WDClientUser.getLoggedInClientUser().getSAPUser().getUniqueName().trim());

input.setUserid(userId);

still it is showing ArrayindexOutOfBound exception.Please tell me What i will do ,Waiting for your reply.

Thanks & Regards

muna

Former Member
0 Kudos

Hi

Try this

1. set the user id hard coded

input.setUserid("Test"); and test it working corectly.

2. If the error message continues It seams that the Bapi structure is changed. Try to remove the model node and re import the Bapi.

Kind Regards

Mukesh

Former Member
0 Kudos

Hi

what is the lenght of your userid. Let me know.

Otherwise hardcoded that userid and try to execute.

Is hardocoded is working or not?

Thanks

Lohi.

Message was edited by: Lohitha M

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi lohith,

I print the length of user id is 7.

Thanks & Regards

muna

Former Member
0 Kudos

Hi lohith,

Actually in backend my user id field size is 30 char,

and i am sending 7 charecter user id.data type of User id

in backend is SysId mentioned by SAP.Please tell me how to solve.

Thanks & Regards

sailajit

Former Member
0 Kudos

Hi

Try this

String userid=String.valueOf(WDClientUser.getLoggedInClientUser().getSAPUser().getUniqueName());

input.setUserid(userid);

or

input.setUserid(String.valueOf(WDClientUser.getLoggedInClientUser().getSAPUser().getUniqueName()));

Kind Regards

Mukesh

Former Member
0 Kudos

Hi

try to implement what mani is mentioned and at the same time.

What u said in SysID is char type only it takes 8 characters only.

U can check the UserId What u send to input.setUserId() any blank spaces are going on then remove blank spaces.

That might helps.

Thanks

Lohi.

Former Member
0 Kudos

Hi gopi and servana,

My problem is not getting user id.I am successfully getting user id.My problem in following line of code

input.setUserid(WDClientUser.getLoggedInClientUser().getSAPUser().getUniqueName());

I already tested that the code

WDClientUser.getLoggedInClientUser().getSAPUser().getUniqueName();

sucessfully retriving user id .My problem is only below

line of code.

input.setUserid(WDClientUser.getLoggedInClientUser().getSAPUser().getUniqueName());

Thanks & Regards

muna

Former Member
0 Kudos

Hi

Did you check with field size of back end Userid and compare the size of printed user.

The statement returns array of unique name. u are trying to store into String.

That might the problem.

Thanks

Lohi.

Former Member
0 Kudos

Hi,

Try this,

IWDClientUser wdUser = WDClientUser.getCurrentUser();

IUser user = wdUser.getSAPUser();

if (user!=null)

{

IUserAccount[] acct = user.getUserAccounts();

if (acct[0]!=null)

{

loginuser=acct[0].getLogonUid();

strUserid += acct[0].getLogonUid();

}

}

Assign the loginuser as a input to the BAPI

import com.sap.security.api

Regards,

Saravanan K

Former Member
0 Kudos

hi

If I got your problem correctly then you are trying to send the looged in user as the input to the RFC that you are calling.

then this code might help you out to capture the logged in user

try{

//IUser user = WDClientUser.forceLoggedInClientUser().getSAPUser();

IUser user = WDClientUser.getLoggedInClientUser().getSAPUser();

IUserAccount[] acct = user.getUserAccounts();

if(acct[0] != null)

{

String strUserid = acct[0].getLogonUid();

customer=strUserid.substring(0,strUserid.indexOf("."));

//wdContext.currentContextElement().setAssoid(new String(strUserid));

if(customer.equalsIgnoreCase(customer))

wdContext.currentYOURRFC_InputElement().setCustomer(customer);

}

}catch(Exception ex)

{

ex.getMessage();

}

let me know if you require some more info.

Thanks,

kris