My problem is that I'm getting a "Pointer not set for location
referenced." which is an MCH3601 on the 400. Which is an indicator,
because I've duplicated the problem using CL, that the output
parameter, parameter 3 in the following code, is not available to the
service program to return the variable into. Now I've twisted and
fought this bad boy by trying ProgramCall and wrapping with CL and all
sorts of stuff but I never get anything back using the CL wrapper or
the base RPG program that this whole mess is trying to run in the first
place. Understand that the INTSVC_SCM/TLSTATUS, module DATE, is a
wrapper to the base program, which is not referred to here and my
mentioning it really does clutter the issue.
The call.run() code returns false and the AS400Message gives me the
reason being the "Pointer not set for location referenced."
So here is the code as best I can give you w/o the debug statements.
public class LTLStatusDAO implements StatusDAO {
static final int dateLength = 8;
private AS400ConnectionPoolWrapper pool = null;
public Status status(BillOfLading bill) {
ServiceProgramCall call =
new ServiceProgramCall(pool.getAS400Connection());
String termId = StringUtil.fillLeft(bill.getTerminalNumber(), '0',
3);
String pro = StringUtil.fillLeft(bill.getProNumber(), '0', 7);
ProgramParameter parmTerm =
new ProgramParameter(
ProgramParameter.PASS_BY_REFERENCE,
new AS400Text(termId.length()).toBytes(termId));
ProgramParameter parmPro =
new ProgramParameter(
ProgramParameter.PASS_BY_REFERENCE,
new AS400Text(pro.length()).toBytes(pro));
// Definition, per documentation, of the output parameter
ProgramParameter parmDate =
new ProgramParameter(
ProgramParameter.PASS_BY_REFERENCE,
date.length());
ProgramParameter[] parmList = new ProgramParameter[3];
parmList[0] = parmTerm;
parmList[1] = parmPro;
parmList[2] = parmDate;
AS400Text convertDate = new AS400Text(dateLength);
try {
call.setProgram(
QSYSObjectPathName.toPath("INTSVC_SCM", "LTLSTATUS", "SRVPGM"));
call.setProcedureName("DATE");
call.setParameterList(parmList);
if (call.run()) {
date =
(String) convertDate.toObject(parmList[2].getOutputData());
} else {
AS400Message[] msgList = call.getMessageList();
log.warn("The program did not run. AS/400");
for (int i = 0; i < msgList.length; i++) {
log.warn(msgList[i].getText());
}
}
} catch (Exception cpe) {
log.error("AS400 Command Connection Pool Failure");
StringWriter string = new StringWriter();
PrintWriter writer = new PrintWriter(string);
cpe.printStackTrace(writer);
log.error(string);
} finally {
pool.getPool().returnConnectionToPool(call.getSystem());
}
return status;
}
Ok, the deal was that I needed to change the RPiG program to not return
a value and just accept values in, by reference, and update those
parameters. So attached is the code that is working wonderfully, sorry
I'm not going to post the RPiG code. Any questions, just post away.
/*
* Created on Oct 9, 2006
*
*/
package com.averitt.core.dao.spring;
import java.io.PrintWriter;
import java.io.StringWriter;
import org.apache.log4j.Logger;
import com.averitt.core.BillOfLading;
import com.averitt.core.Status;
import com.averitt.core.StatusImpl;
import com.averitt.core.dao.StatusDAO;
import com.averitt.datetime.DateTimeHelper;
import com.averitt.util.basic.StringUtil;
import com.ibm.as400.access.AS400Message;
import com.ibm.as400.access.AS400Text;
import com.ibm.as400.access.ProgramParameter;
import com.ibm.as400.access.QSYSObjectPathName;
import com.ibm.as400.access.ServiceProgramCall;
/**
* @author jfinley
*
*/
public class LTLStatusDAO implements StatusDAO {
Logger log = Logger.getLogger(LTLStatusDAO.class);
static final int dateLength = 8;
static final int codeLength = 3;
static final int descriptionLength = 15;
private AS400ConnectionPoolWrapper pool = null;
/* (non-Javadoc)
* @see
com.averitt.core.dao.spring.StatusDAO#status(com.averitt.core.BillOfLading)
*/
public Status status(BillOfLading bill) {
log.debug("status(BillOfLading bill)");
log.debug("Pool: " + pool);
ServiceProgramCall call =
new ServiceProgramCall(pool.getAS400Connection());
Status status = new StatusImpl();
String description = StringUtil.fillLeft(" ", ' ',
descriptionLength);
String code = StringUtil.fillLeft(" ", ' ', codeLength);
String date = StringUtil.fillLeft(" ", ' ', dateLength);
String termId = StringUtil.fillLeft(bill.getTerminalNumber(), '0',
3);
String pro = StringUtil.fillLeft(bill.getProNumber(), '0', 7);
ProgramParameter parmTerm =
new ProgramParameter(
ProgramParameter.PASS_BY_REFERENCE,
new AS400Text(termId.length()).toBytes(termId));
ProgramParameter parmPro =
new ProgramParameter(
ProgramParameter.PASS_BY_REFERENCE,
new AS400Text(pro.length()).toBytes(pro));
ProgramParameter parmDate =
new ProgramParameter(
ProgramParameter.PASS_BY_REFERENCE,
date.length());
ProgramParameter parmCode =
new ProgramParameter(
ProgramParameter.PASS_BY_REFERENCE,
code.length());
ProgramParameter parmDesc =
new ProgramParameter(
ProgramParameter.PASS_BY_REFERENCE,
description.length());
ProgramParameter[] parmList = new ProgramParameter[5];
parmList[0] = parmTerm;
parmList[1] = parmPro;
parmList[2] = parmDate;
parmList[3] = parmCode;
parmList[4] = parmDesc;
AS400Text convertDesc = new AS400Text(descriptionLength);
AS400Text convertCode = new AS400Text(codeLength);
AS400Text convertDate = new AS400Text(dateLength);
try {
log.debug("Setting the program to run");
call.setProgram(
QSYSObjectPathName.toPath("INTSVC_SCM", "LTLSTATUS", "SRVPGM"));
call.setProcedureName("ALLELEMENTS");
log.debug("Setting the parm list");
call.setParameterList(parmList);
log.debug(call.getServerJob());
log.debug("Running");
log.debug("Inputs are: ");
if (call.run()) {
log.debug("Trying to fetch out the returned values");
date =
(String) convertDate.toObject(parmList[2].getOutputData());
code =
(String) convertCode.toObject(parmList[3].getOutputData());
description =
(String) convertDesc.toObject(parmList[4].getOutputData());
status.setCode(code);
status.setDescription(description);
status.setDate(DateTimeHelper.getDate(date, "yyyyMMdd"));
log.debug("Outputs are: ");
log.debug("The date is: " + date);
log.debug("The description is: " + description);
log.debug("The code is: " + code);
} else {
AS400Message[] msgList = call.getMessageList();
log.warn("The program did not run. AS/400");
for (int i = 0; i < msgList.length; i++) {
log.warn(msgList[i].getText());
}
}
} catch (Exception cpe) {
log.error("AS400 Command Connection Pool Failure");
StringWriter string = new StringWriter();
PrintWriter writer = new PrintWriter(string);
cpe.printStackTrace(writer);
log.error(string);
} finally {
pool.getPool().returnConnectionToPool(call.getSystem());
}
return status;
}
/**
* @return
*/
public AS400ConnectionPoolWrapper getPool() {
return pool;
}
/**
* @param wrapper
*/
public void setPool(AS400ConnectionPoolWrapper wrapper) {
pool = wrapper;
}
}
--
Kent Milligan
ISV Enablement - System i
km...@us.eye-bee-m.com (spam trick) GO HAWKEYES!!
>>> ibm.com/iseries/db2
(opinions stated are not necessarily those of my employer)