当我从java调用RPG程序时,我能够传递输入参数并尝试从相同的输入字段获取输出值,当它来到java时它获得NullPointerException。这是我的示例代码。 请提出解决方案。
try{
AS400 sys=new AS400("domain","user","password");
ProgramParameter[] parmList = new ProgramParameter[2];
AS400ZonedDecimal laonNumner = new AS400ZonedDecimal(10,0);
AS400ZonedDecimal loanAmt = new AS400ZonedDecimal(10,3);
parmList[0] = new ProgramParameter(laonNumner.toBytes(12345));
parmList[1] = new ProgramParameter(loanAmt.toBytes(6789));
String pgmName = "/QSYS.LIB/VTEST.LIB/TESTRPG.PGM";
ProgramCall pgm = new ProgramCall(sys,pgmName,parmList);
CommandCall command = new CommandCall(sys);
command.run("ADDLIBLE LIB(VTEST)");
System.out.println("status :"+pgm.isRunning());
if (pgm.run()!=true) {
System.out.println("failure");
AS400Message[] messageList = pgm.getMessageList();
System.out.println(messageList.length);
for (int i=0; i < messageList.length; i++)
{
System.out.print ( messageList[i].getID() );
System.out.print ( ": " );
System.out.println( messageList[i].getText() );
}
}else{
System.out.println("success" );
Double loanNo = laonNumner.toDouble(parmList[0].getOutputData());
Double loanAmount = laonNumner.toDouble(parmList[1].getOutputData());
System.out.println("Loan number"+ loanNo);
System.out.println("Loan number"+ loanAmount);
}
System.out.println("status :"+pgm.isRunning());
sys.disconnectAllServices();
}catch(Exception e) {
System.out.println(e.toString());
}
输出:
status :false
success
java.lang.NullPointerException
答案 0 :(得分:0)
你有输入/输出参数,所以你想在调用程序之前调用ProgramParameter对象上的setOutputLength()方法。
parmList[0] = new ProgramParameter(laonNumner.toBytes(12345));
parmList[0].setOutputLength(50)
parmList[1] = new ProgramParameter(loanAmt.toBytes(6789));
parmList[1].setOutputLength(50)