{
return XMLHelper.parseXML(getTestData(function), null, null);
}
// Conect to the iSeries
AS400 as400 = as400Connection.getSystem();
// Character converter
try
{
mConverter = new CharConverter(as400.getCcsid());
}
catch (UnsupportedEncodingException e)
{
throw new XException(Constants.LOCATION_EXTERN,
Constants.LAYER_TECHNICAL,
Constants.PACKAGE_TECHNICAL_AS400, "0", e);
}
// Determine how to operate
String callType = config.getValue("AS400Program", function, "CallType");
if (!CALLTYPE_SINGLE.equals(callType)
&& !CALLTYPE_MULTI.equals(callType))
{
List params = new Vector();
params.add(callType);
throw new XException(Constants.LOCATION_EXTERN,
Constants.LAYER_TECHNICAL,
Constants.PACKAGE_TECHNICAL_AS400, "39", params);
} // if (!CALLTYPE_SINGLE.equals(callType) &&
// !CALLTYPE_MULTI.equals(callType))
if (CALLTYPE_SINGLE.equals(callType))
{ // Only one calling step, only one record wil be returned as result
// Read the name of the programm from the configuration
String programName = config.getValue("AS400Program", function,
"Program");
// Structure for input an (still empty) output parameters
ProgramParameter[] parameters = getParametersFromDocument(
(Document) callData, callType, function, 1, 1);
// the program call itself
callAS400Program(as400, programName, parameters, timeout);
// Get the output values.
List outputList = makeOutputFields(as400, parameters, 1);
// Place output values in specified XML structure.
response = getResponseDocument(function, outputList);
} // then (CALLTYPE_SINGLE.equals(callType))
else if (CALLTYPE_MULTI.equals(callType))
{ // Call multiple times to get entire list of output data
// First call will determine amount of returned records.
// Next phase is to call (another program) to get each time one
// record.
// Read the name of the output count determining program from the
// configuration
String programNameAmount = config.getValue("AS400Program",
function, "ProgramAmount");
// Read the e
String programNameData = config.getValue("AS400Program", function,
"ProgramData");
/*
* First call of the AS400 program to get the amount of rows to be
* retrieved.
*/
// Structure for input an (still empty) output parameters
ProgramParameter[] parameters = getParametersFromDocument(
(Document) callData, callType, function, 1, 1);
// The first program call itself
callAS400Program(as400, programNameAmount, parameters, timeout);
// Number of result records to retrieve in next calling phase
int recordAmount = getParameterAsInt(as400, parameters, 1);
/*
* Subsequent calls of the AS400 program to get all rows.
*/
// for the result records
List outputVector = new Vector();
// Loop over all result records - count already known
for (int row = 0; row < recordAmount; row++)
{
// Structure for input an (still empty) output parameters
parameters = getParametersFromDocument((Document) callData,
callType, function, 2 + row, 1);
// The program call itself
callAS400Program(as400, programNameData, parameters, timeout);
// Retrieve result record and add it to list
outputVector.addAll(makeOutputFields(as400, parameters, 1));
} // for (int row=0; row<recordAmount; row++)
response = getResponseDocument(function, outputVector);
} // if (CALLTYPE_MULTI.equals(callType))
// Done with the server
as400.disconnectService(AS400.COMMAND);
return response;
} // execute(String function, Object callData)