Skip to Content
0
Former Member
Jul 12, 2010 at 02:32 PM

JCO input Parameter Structures : BAPI_USER_CHANGE

1122 Views

Hi Experts,

I have a JCO connection calling bapi (BAPI_USER_CHANGE) to reset user's password.

I am passing USERNAME, PASSWORD and PASSWORDX. However I am getting an error when password PASSWORD:

"Cannot convert a value of '5qtzsRMVRn' from type java.lang.String to STRUCTURE at field PASSWORD"

I may have to get structure first, but when what to I assign it to?

String newPassword = getRandomString();
    
    try{
		JCO.Function bapiUserChange = repository.getFunctionTemplate("BAPI_USER_CHANGE").getFunction();
		if(bapiUserChange != null){
			JCO.ParameterList userChangeInput = bapiUserChange.getImportParameterList();
			
			JCO.Structure sPassword = userChangeInput.getStructure("PASSWORD");
			
			//sPassword.setValue(newPassword, ????) //what do I assign it to?
			
			userChangeInput.setValue(userId, "USERNAME");
			userChangeInput.setValue(newPassword, "PASSWORD");  // this gives an error
			userChangeInput.setValue("X","PASSWORDX"); //I know "X" is true, this will give an error too I believe
			
			mConnection.execute(bapiUserChange);
			
			//send E-mail
			boolean emailSent = sendEmail(userId, newPassword, "XXX200");
			msgMgr.reportSuccess("Password Reset Done");	
			
			if(mConnection != null){
				mConnection.disconnect();
			}
					
		}
    }catch(Exception e){
    	msgMgr.reportException("Could not change password " + e.getMessage(),true);
    }