Skip to content

Instantly share code, notes, and snippets.

@greghelton
Created July 29, 2016 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save greghelton/380782cc12ad331e0aef5bc32628cf19 to your computer and use it in GitHub Desktop.
Save greghelton/380782cc12ad331e0aef5bc32628cf19 to your computer and use it in GitHub Desktop.
import com.ibm.as400.access.*;
public class PollDtaq {
DataQueue readQ;
AS400 as400;
ProgramCall program;
/*
* compile: javac -cp .;..\jars\jt400.jar PollDtaq.java
*/
public PollDtaq() {
this.as400 = new AS400("DPITEST", "as400userid", "password");
this.readQ = new DataQueue(as400, "/QSYS.LIB/GAH285.LIB/TESTINGQ.DTAQ");
this.program = new ProgramCall(this.as400);
}
public void writeQ(String data) throws Exception {
String programName = "/QSYS.LIB/GAH285.LIB/WRITEDTAQ.PGM";
ProgramParameter[] parameterList = new ProgramParameter[1];
AS400Text nametext = new AS400Text(100);
parameterList[0] = new ProgramParameter(nametext.toBytes(data));
program.setProgram(programName, parameterList);
if (!program.run()) {
System.out.println("write to DTAQ failed");
}
}
public String getData() throws Exception {
String data = readQ.read().getString();
return data;
}
public static void main(String[] args) throws Exception {
PollDtaq pd = new PollDtaq();
pd.writeQ("Good Morning");
System.out.println(pd.getData());
}
}
pgm &Data
Dcl &Data *Char (100)
Dcl &QueueName *Char (10) Value('TESTINGQ')
Dcl &QueueLib *Char (10) Value('GAH285')
DCL &DataLength *DEC (5 0) Value(100)
CRTDTAQ DTAQ(GAH285/TESTINGQ) MAXLEN(100)
MONMSG CPF0000 EXEC()
Call QSndDtaQ (&QueueName +
&QueueLib +
&DataLength +
&Data)
endpgm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment