1

我正在尝试使用 BAPI_USER_CHANGE 重置 sap 用户的密码,但由于“密码不是输入字段类型”而出现错误。我在下面发布我的代码。这里 getRandomString() 是用户定义函数。我从互联网上复制了这段代码,我完全不知道这个函数。

    public static void resetSAPPwd()
    {
      //String newPassword = getRandomString();
        String newPassword ="mypwd";       
        String userId="myid";
    try{

          JCoDestination destination = JCoDestinationManager.getDestination(DESTINATION_NAME2);
          System.out.println("getRepositoryUser for resetSAPPwd : "+destination.getRepositoryUser());
          JCoFunction bapiUserChange = destination.getRepository().getFunction("BAPI_USER_CHANGE");

          System.out.println("1 check fn:  ");

         if(bapiUserChange != null){
              JCoParameterList userChangeInput = bapiUserChange.getImportParameterList();

                System.out.println("JCoParameterList object userChangeInput ............. :"+userChangeInput);    

                    JCoStructure sPassword = userChangeInput.getStructure("PASSWORD");
                    JCoStructure sPasswordx = userChangeInput.getStructure("PASSWORDX");

                    sPassword.setValue(newPassword, "BAPIPWD");
                    System.out.println("0");
                    sPasswordx.setValue('X', "BAPIPWD");
                    System.out.println("1");
                    userChangeInput.setValue(userId, "USERNAME");
                    //userChangeInput.setValue(sPassword, "PASSWORD"); 
                    //userChangeInput.setValue(sPasswordx,"PASSWORDX");
                    System.out.println("2");
                    bapiUserChange.execute(destination);

               System.out.println("Reset Pwd Done.......... ");

          }
    }catch(Exception e){
        System.out.println(e.getMessage());
    }

}

4

0 回答 0