title: how to reset password in SAP using BAPI?
body: <p>I am trying to reset password for SAP using bapi but i am getting error as "password is not type of field input".  </p>
  
  <p>I am posting my code below.  </p>
  
  <p>Here <code>getRandomString()</code> is user defined function.  I have copied this code from Internet and I am unaware about this.</p>
  
  <pre><code>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);
  }
  </code></pre>
  
  <hr>
  
  <p>but <code>String newPassword = getRandomString();</code> here it is giving error because <code>getRandomString()</code> is user defined function and i am unaware about this.Is there any role of this while reseting password or I can directly use <code>String newpassword=" ";</code></p>