cancel
Showing results for 
Search instead for 
Did you mean: 

Update the User Account attributes stored in UME programatically

Former Member
0 Kudos

Hi Experts,

How can we update the user account attributes (like Email-Id, First Name, last Name etc.) stored in UME database programatically through Web dynpro java?

Kindly assist.

Best Regards,

Anurag

Accepted Solutions (1)

Accepted Solutions (1)

vijay_kumar49
Active Contributor
0 Kudos

Hi Anurag Gwari,

Please look at this code


public void onActionupdateUser(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
//@@begin onActioncreateUser(ServerEvent)
try { 
                  IUserFactory factory = UMFactory.getUserFactory();
                  IUserAccountFactory accountFactory = UMFactory.getUserAccountFactory(); 
                  String email = wdContext.currentContextElement().getEmail();
                  String fname = wdContext.currentContextElement().getFirstname();
                  String lname = wdContext.currentContextElement().getLastname();
                 String password = wdContext.currentContextElement().getPassword();
                 String userid = wdContext.currentContextElement().getUserid(); 
                  IUserMaint newUser = factory.newUser(userid); 
                 newUser.setFirstName(fname);
                 newUser.setLastName(lname);
                 newUser.setEmail(email);
                newUser.update();
               newUser.commit(); 
               IUserAccount account = accountFactory.newUserAccount(userid,newUser.getUid());
              account.setPassword(password);
              account.update();
              account.commit(); 
            wdComponentAPI.getMessageManager().reportSuccess("User updated..........."+userid);
}
catch (UMException e)
{
// TODO Auto-generated catch block    
       wdComponentAPI.getMessageManager().reportException(e.getMessage(),false);
       e.printStackTrace();
} 

Please look the SAP wiki: [How to create Portal User by using Web Dynpro Java|http://wiki.sdn.sap.com/wiki/display/WDJava/HowtocreatePortalUserbyusingWebDynpro+Java]

I hope this is help full for you,

Regards

Vijay

Former Member
0 Kudos

Hi,

The question was resolved.

Could not update earlier.

Best Regards,

Anurag

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Anurag,

I am having the same requirement to update the email id of existing user in SAP Portal.

For this purpose i have written the code ..

try
{
IUserFactory factory = UMFactory.getUserFactory();
IUserAccountFactory accountFactory = UMFactory.getUserAccountFactory();
String email = wdContext.currentPortalUserElement().getEmailid();
String userid = wdContext.currentPortalUserElement().getEmployeeID();

  
IUserMaint newUser = factory.newUser(userid);

newUser.setEmail(email);
        newUser.save();     // Here I am not getting update method
newUser.commit();
IUserAccount account = accountFactory.newUserAccount(userid,newUser.getUid());
account.save();
account.commit();
wdComponentAPI.getMessageManager().reportSuccess("User Created..........."+userid);

}
catch(UMException e)
{
wdComponentAPI.getMessageManager().reportSuccess(""+e);
}

But this code create a new user if user doesnot exist and if user exist than it will throw the exception User Already Exist..

And also I am not getting the update method instead of update method i am getting only save() .

Please reply ASAP.

Regards,

Nitin

Former Member
0 Kudos

Resolved.

Former Member
0 Kudos

Hi Anurag,

Could you please throw some light on how this was resolved? We seem to have a scenario where this would be the appropriate solution.

Our scenario: Customer logs in and updates his/her email address in the "Customer Data" page. This change is immediately reflected in the BP data on ECC. However, the email address is not updated in UME.

Maybe we could apply a solution similar to yours to achieve the required result.

Thanks,

Chiranth

Former Member
0 Kudos

Hi Chiranth,

Please confirm the following points:

  • Where does the customer log on to change his/her email address, is it SAP Portal or some sap application?
  • Process followed by the customer to change the email address. This will help in understanding the trigger point to update the email address in UME.

Regards,

Anurag