Accessing RPG on iSeries from Java(从 Java 访问 iSeries 上的 RPG)
问题描述
Has anyone had good experiences of talking direct to RPG programs running on a V5R4 iSeries machine from Java? If so, what are the recommendations of the community, and what pitfalls should I try to avoid?
From the various pieces of literature and spike solutions I have attempted it looks as though we can use ProgramCallBeans (either through PCML or xPCML), talking to the DataQueues (for asynchronous comms), or even JNI.
I'm looking for something that's robust, performant, quick to develop, easy to maintain, and easy to test (aren't we all!?!).
I suggest using IBM's Java Toolbox for Java. Put the JT400.jar into your classpath (or JT400Ntv.jar if the Java is running on the iSeries). I've used both the ProgramCall class and the CommandCall classes.
The com.ibm.as400.access.CommandCall class is easy to use. It has a simple constructor that you pass a com.ibm.as400.access.AS400 class to. Then just use the run method like this:
CommandCall command = new CommandCall(as400);
command.run("CPYF FROMFILE(BLAH) TOFILE(BLAHBLAH) CRTFILE(*YES)");
Of course, you wouldn't use that particular CL command, but you get the idea. When using the CommandCall class, it's always a good idea to process any messages that came from the command. In the one program I use this for, I display the messages to the user in a textbox on their screen like this:
AS400Message[] messageList = command.getMessageList();
for (int i=0;i < messageList.length;i++) {
String sMessageText = messageList[i].getText();
sMessage+=sMessageText + "
";
}
The com.ibm.as400.access.ProgramCall class takes more work, but it allows you to access the returned parameters. I use this one more often because I'm usually calling existing RPG worker programs that return values. For this, define a com.ibm.as400.access.ProgramParameter array. When you pass parameters to a program from Java, remember to convert them to AS/400-friendly values using a class like com.ibm.as400.access.AS400Text. The details of the ProgramCall command are better researched using IBM's documentation: http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=/rzahh/page1.htm
这篇关于从 Java 访问 iSeries 上的 RPG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:从 Java 访问 iSeries 上的 RPG
基础教程推荐
- Spring Boot Freemarker从2.2.0升级失败 2022-01-01
- 如何对 HashSet 进行排序? 2022-01-01
- 如何强制对超级方法进行多态调用? 2022-01-01
- 首次使用 Hadoop,MapReduce Job 不运行 Reduce Phase 2022-01-01
- Java 中保存最后 N 个元素的大小受限队列 2022-01-01
- 由于对所需库 rt.jar 的限制,对类的访问限制? 2022-01-01
- 在螺旋中写一个字符串 2022-01-01
- 如何使用 Stream 在集合中拆分奇数和偶数以及两者的总和 2022-01-01
- 如何使用 Eclipse 检查调试符号状态? 2022-01-01
- 如何在不安装整个 WTP 包的情况下将 Tomcat 8 添加到 Eclipse Kepler 2022-01-01