如何使用 BAPI 在 SAP 中重置密码? [英] how to reset password in SAP using BAPI?

查看:41
本文介绍了如何使用 BAPI 在 SAP 中重置密码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 bapi 为 SAP 重置密码,但我收到错误消息,因为密码不是字段输入类型".

I am trying to reset password for SAP using bapi but i am getting error as "password is not type of field input".

我在下面发布我的代码.

I am posting my code below.

这里 getRandomString() 是用户定义的函数.我从网上复制了这段代码,我不知道这一点.

Here getRandomString() is user defined function. I have copied this code from Internet and I am unaware about this.

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=" ";


but String newPassword = getRandomString(); here it is giving error because getRandomString() is user defined function and i am unaware about this.Is there any role of this while reseting password or I can directly use String newpassword=" ";

推荐答案

参数 PASSWORD 的类型为 BAIPWD,这是一个结构,它只包含一个字段名为 BAIPWD.因此,您需要大致像这样访问结构:

The parameter PASSWORD is typed as BAPIPWD which is a structure what in turn contains only a single field named BAPIPWD. Therefore, you need to access the structure approximately like this:

JCO.Structure sPassword = userChangeInput.getStructure("PASSWORD");
sPassword.setValue(newPassword, "BAPIPWD");

这篇关于如何使用 BAPI 在 SAP 中重置密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆