Hi all,
Can anyone give me some tips regarding a problem I'm having?
So we're doing some project using Websphere to integrate with iSeries (we achieved to access DB2 on iSeries, calling RPG programs using ProgramCall, etc..). Until here everything OK, our problem is related with the following:
Imagine we're on iSeries and call a RPG program that does the following:
· Fulfill Data Structure (1)
· Call X.PGM with DS as parameter (2)
o Eval return parameter, if OK then: (3)
§ Change a field value on the input DS (4)
§ Call X.PGM with DS (5)
· Print return parameter (the return is OK) (6)
Hope that my bullets explanation were representative. :)
Ok so when we emulate this on the Java (doing the same steps the program called from iSeries does), we're getting some error on step 6 (saying that the program didn't find any reference...) - we think this is because the two ProgramCall calls occurs in different contexts (or the second call doesn't have the first call context).
On our code we're reusing the ProgramCall, we've just change the parameter value using ProgramParameter.setInputData(). Is it possible to have the same behavior on Java that we have on RPG program?
Sample code below:
AS400 sys = session.getSystem();
String pgmPath = QSYSObjectPathName.toPath("XPTOLIB", "PROGRA", "PGM");
Object[] inData = ...;
ProgramParameter[] parameters = new ProgramParameter[] {
new ProgramParameter(DATATYPES[0].toBytes(inData[0]), ..),
new ProgramParameter(DATATYPES[1].toBytes(inData[1]), ..),
new ProgramParameter(DATATYPES[2].toBytes(inData[2]), ..),
new ProgramParameter(DATATYPES[3].toBytes(inData[3]), ..),
new ProgramParameter(DATATYPES[4].toBytes(inData[4]), ..),
new ProgramParameter(DATATYPES[4].toBytes(inData[4]), ..),
new ProgramParameter(DATATYPES[6].toBytes(inData[6]), ..),
new ProgramParameter(DATATYPES[7].toBytes(inData[7]), ..),
new ProgramParameter(DATATYPES[8].toBytes(inData[8]), ..),
new ProgramParameter(DATATYPES[9].toBytes(inData[9]), .),
new ProgramParameter(DATATYPES[10].toBytes(inData[10]), ..),
new ProgramParameter(DATATYPES[11].toBytes(inData[11]), .),
new ProgramParameter(DATATYPES[12].toBytes(inData[12]), ..)
};
ProgramCall pgm = new ProgramCall(sys);
boolean success = false;
try {
// first call
success = pgm.run(pgmPath, parameters);
if (!success) {
throw new ConnectionException("We've received success=false.");
}
System.out.println("job number: " + pgm.getServerJob().getNumber());
}
catch (Exception e) {
...// do logging etc..
}
outData = ...// process array parameters[...].getOutputData();
printResponse(outData);
String status = outData[6].toString();
if ("R".equals(status)) {
try {
parameters[5].setInputData(dsaim2);
} catch (PropertyVetoException e1) {
e1.printStackTrace(); // test purpose only
}
success = false;
try {
// second call
success = pgm.run(h56h1r, parameters);
if (!success) {
throw new ConnectionException("We've received success=false.");
}
System.out.println("job number: " + pgm.getServerJob().getNumber());
}
catch (Exception e) {
...// do logging etc..
}
outData = ...// process array parameters[...].getOutputData();
// were we see on the console the problem
printResponse(outData);
Thanks in advance!
Tiago Cavaleiro
________________________________
Disclaimer/Implicações legais
http://www.exictos.com/disclaimer/e-mail.htm
________________________________
Antes de imprimir este "e-mail" pense no meio ambiente.
Por favor considere as suas responsabilidades ambientais! Antes de imprimir o Email, pergunte a si mesmo se realmente precisa duma cópia em papel.
As an Amazon Associate we earn from qualifying purchases.