1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
AS400 as400 = new AS400(prop.getProperty("AS400_MACHINE"));
System.out.println("Connexion a " + prop.getProperty("AS400_MACHINE") + " => OK");
ProgramCall program = new ProgramCall(as400);
try
{
// Initialize the name of the program to run.
String programName = "/QSYS.LIB/MABIB.LIB/MONPGM.PGM";
// Set up the 3 parameters.
//ProgramParameter[] parameterList = new ProgramParameter[4];
ProgramParameter[] parameterList = new ProgramParameter[] {
new ProgramParameter(36),
new ProgramParameter(36),
new ProgramParameter(11),
new ProgramParameter(02)
};
// First parameter is to input a name.
AS400Text MonParam = new AS400Text(36, as400);
parameterList[0] = new ProgramParameter(MonParam.toBytes(randomString(16)), 36);
//AS400Text AS400_Inutile = new AS400Text(36, as400);
parameterList[1] = new ProgramParameter(MonParam.toBytes("321654498797546786"), 36);
//AS400Text AS400_NoTiers = new AS400Text(11, as400);
parameterList[2] = new ProgramParameter(MonParam.toBytes("10280599501"), 11);
//AS400Text AS400_CodeRetour = new AS400Text(2, as400);
parameterList[3] = new ProgramParameter(MonParam.toBytes("AA"), 2);
//parameterList[4] = new ProgramParameter(AS400_CodeRetour.toBytes(""));
// Set the program name and parameter list.
program.setProgram(programName, parameterList);
// Run the program.
if (program.run() != true)
{
// Report failure.
System.out.println("Program failed!");
// Show the messages.
AS400Message[] messagelist = program.getMessageList();
for (int i = 0; i < messagelist.length; ++i)
{
// Show each message.
System.out.println(messagelist[i]);
}
}
// Else no error, get output data.
else
{
AS400Text text = new AS400Text(32, as400);
for (int i = 0; i < parameterList.length; ++i)
{
// Show each message.
System.out.println(text.toObject(parameterList[i].getOutputData()) + "<------");
}
// System.out.println(text.toObject(parameterList[0].getOutputData()));
// System.out.println(text.toObject(parameterList[1].getOutputData()));
// System.out.println(text.toObject(parameterList[2].getOutputData()));
// System.out.println(text.toObject(parameterList[3].getOutputData()));
}
}
catch (Exception e)
{
System.out.println("Program " + program.getProgram() + " issued an exception!");
e.printStackTrace();
Listener_Stop = true;
} |
Partager