1

I am trying to call the API QtocRtvTCPA in /QSYS.LIB/QTOCNETSTS.SRVPGM in v7r3 via jtOpen/jt400. parameter[3] is defined as ErrorCode in the API
https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_73/apis/qtocrtvtcpa.htm
Every attempt I have made to call the service program has resulted in the error at the bottom. I have tried all the items that are commented out below. I could use some help in determining how to pass the error code parameter.

    private byte[] receiverVariable = new byte[1000];
parameters[0].setOutputDataLength(receiverVariable.length);
    parameters[1].setInputData(bin4.toBytes(receiverVariable.length));
    parameters[2].setInputData(new AS400Text(8).toBytes("TCPA0200"));
    //parameters[3] = new ErrorCodeParameter();
    //parameters[3] = new ProgramParameter(BinaryConverter.intToByteArray(0));
    //parameters[3] = new ProgramParameter(new AS400Text(8).toBytes("ERRC0100"), 0);
    //parameters[3] = new ProgramParameter(new AS400Text(8).toBytes("ERRC0200"), 0);
    //parameters[3] = new ProgramParameter(0);
    ServiceProgramCall sPGMCall = new ServiceProgramCall(as400);
    sPGMCall.setProgram("/QSYS.LIB/QTOCNETSTS.SRVPGM", parameters);
    sPGMCall.setProcedureName("QtocRtvTCPA");
      sPGMCall.setReturnValueFormat(ServiceProgramCall.NO_RETURN_VALUE);

Error code parameter not valid.
CPF3CF1
AS400Message (ID: CPF3CF1 text: Error code parameter not valid.):com.ibm.as400.access.AS400Message@1536d79
Cause . . . . . : The format of the error code parameter is not correct. Recovery . . . : Correct the error code parameter and try the request again. If you do not know the correct format for the error code parameter, see the APIs topic collection in the Programming category in the IBM i Information Center, http://www.ibm.com/systems/i/infocenter/.

user1838913
  • 103
  • 6

1 Answers1

3

The solution

            parameters[3].setInputData(bin4.toBytes(0));

        parameters[0].setParameterType(ProgramParameter.PASS_BY_REFERENCE);
        parameters[1].setParameterType(ProgramParameter.PASS_BY_REFERENCE);
        parameters[2].setParameterType(ProgramParameter.PASS_BY_REFERENCE);
        parameters[3].setParameterType(ProgramParameter.PASS_BY_REFERENCE);
user1838913
  • 103
  • 6