java如何使用BAPI在SAP中重置密码?
我试图使用bapi重置SAP的密码,但由于“密码不是字段输入类型”而出现错误
我在下面发布我的代码
这里getRandomString()
是用户定义的函数。我从互联网上复制了这段代码,对此我一无所知
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);
}
但是String newPassword = getRandomString();
这里给出了错误,因为getRandomString()
是用户定义的函数,我不知道这一点。重置密码时是否有此角色,或者我可以直接使用String newpassword=" ";
# 1 楼答案
参数
PASSWORD
被类型化为BAPIPWD
,这是一种结构,它只包含一个名为BAPIPWD
的字段。因此,您需要访问结构,大致如下所示:# 2 楼答案
尝试使用BAPIPWD或PASSWORD-BAPIPWD代替PASSWORD,以防万一,请确保密码都是大写的