on 06-06-2014 11:31 AM
Hello Gurus,
I have an application where i need to pass the currently logged in user ID into an input field, on that ID his employee smartform will be displayed via RFC. please send me the code to do so.
Dear Shilpi,
1. Add component tc/je/usermanagement/api as a 'Used DC' (NW 7.0) / 'Required DC' (NW7.11 and up)
2. Use the below code to get the logged in User
try
{
IWDClientUser CurrentUser = WDClientUser.getCurrentUser();
String UserId = WDClientUser.getCurrentUser().getSAPUser().getUniqueName();
}
catch(Exception e)
{
e.printStackTrace();
}
Thanks & Regards,
Patralekha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi All,
My problem got solved as i have rearranged my code and paste it in initialization to show the smart form on click of the tab according to the currently logged in user.
thank you everyone for helping me out.
thanks alot
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I created two applications on the same RFC, in one of the applications the employee id is manually inputted and there is no error for the same. But when the currently logged in user id is fetched automatically, it is showing error.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi shipi,
In the second case , where you told that on fetching the currently logged user id ... u r getting error , it shows while creating applicaiton you have not checked the authentication check box.
No worries for this component you have created application right ,
double click the applicaiton, it opens application properties at the right hand side.
now in the right hand side you have properties and application properites , choose Application properties tab.
Click New Button->
Now click Browse ->Choose Authentication -->In value drop down Choose True --now click finish
now build your dc and deploy the same.
like since you have not applied authentication to your application so wdclient.getuser...etc will give null
now if you enable authentication to your application then it fetches the user.
Regards
Govardan Raj S
Hi Gurus,
I use this code and my application is working very fine. When I am deploying the application, form is coming according to currently logged in user but it is also showing error
Fill in all required entry fields , error key: RFC_ERROR_SYSTEM_FAILURE |
The code for user from display is:
try
{
WDClientUser.getCurrentUser().getSAPUser().getUniqueName();
user = WDClientUser.getCurrentUser().getSAPUser().getUniqueName();
//wdContext.currentZfm_Empform_Portal_InputElement().setUsrid(CurrentUser());
}
catch(Exception e)
{
e.printStackTrace();
}
//String UserId1 = UserId;
try
{
//wdContext.currentZfm_Empform_Portal_InputElement().setUsrid(wdContext.currentZfm_Empform_Portal_InputElement().getUsrid());
wdContext.currentZfm_Empform_Portal_InputElement().setUsrid(user);
wdContext.currentZfm_Empform_Portal_InputElement().modelObject().execute();
}
catch (WDDynamicRFCExecuteException e)
{
e.printStackTrace();
wdContext.currentContextElement().setPdf_data(e.getMessage());
}
wdContext.currentContextElement().setPdf_data(convertXStringToURL(wdContext.currentOutputElement().getBin_File()));
please help me to resolve this issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear shilpi,
In your RFC , some input attributes will be manadatory , check with your abaper , it is getting passed empty i mean no value is being passed to the rfc for that mandatory attribute .
so only you are getting rfc_error_system_failure..
Ask your abaper to give the test Data for executing the rfc, hard code those values and check the execution..
in the exception block as suggested earlier
StringWriter StrWriter = new StringWriter();
Mylog.Myloc.errorT(StrWriter.toString());
PrintWriter PntWWriter = new PrintWriter(StrWriter);
StrWriter.getBuffer().setLength(0);
exception.printStackTrace(PntWWriter);
Mylog.Myloc.errorT(wdComponentAPI.getApplication().getName()+StrWriter.toString());
and create myLoc class in the
//@beging others
public static class Mylog
{
private static final Location Myloc = Location.getLocation("com.yourorg.MyLogController");
}
//@end others
you will get in detailed info in the nwa logs and traces..
Hi can u please post your error complete giving much more details.....?
Regards
Govardan
hi ,
on click of display button ,
what is the code being executed , there as suggested can u put in try catch block and post the logs that are coming in nwa , or else you can put this in exception block.
//-------------------------------------------
catch (Exception e)
{
StackTraceElement element[] = e.getStackTrace();
StringBuffer buffer = new StringBuffer();
for(int i=0;i<element.length;i++)
{
buffer.append(element[i]);
}
wdComponentAPI.getMessageManager().reportException(buffer.toString(),true);
}
//-----------------------------------------
it will show the exactl line number where dump occurs we can trace the error easily...
Regards
Govardan Raj
thank u gurus for ur instant help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Shilpi.
WDClientUser.getCurrentUserOrNull().getSAPUser().getUniqueName()
this will return the current user logon id.
Regards Tobias.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.