| TechTip: RPG Talks to the Desktop |
|
|
|
| Tips & Techniques - RPG | ||||||
| Written by Aaron Bartell | ||||||
| Tuesday, 06 November 2007 18:00 | ||||||
|
This article provides instructions (and actual code) for integrating your RPG programs with the desktop by using a relatively small amount of Java. The basic concept is that you provide a non-intrusive Java application on each PC that needs to receive calls from RPG, and when you start the Java client, it just sits in a wait state to receive commands from your RPG program. When I say "commands," I really mean any value you want to send down to the PC; the key is to have Java handle it appropriately. The Java client receives commands and executes them using rundll32, which is a nifty tool on your Windows PC that allows the execution of command-line access programs. Connecting the PC to System i5 is done using IBM's Java Toolbox and keyed data queues. Each PC will be listening to the same data queue as all other PCs using the utility (i.e., MYLIB/MYDQ), but being that it is keyed, it will only listen for the specific value it has been configured for. When the RPGToDesktop.java application starts, you will pass a variety of parameters, including the unique key used for data queue listening. On the PC side, there are three files used in the process: RPG2DT.jar, jt400.jar, and Start_RPGToDesktop.bat. The Start_RPGToDesktop.bat file is simply used to more easily invoke the listener, RPG2DT.jar. You will need to edit the Start_RPGToDesktop.bat file in Notepad (or equivalent) to use your System i5 IP address, profile, password, etc. The jt400.jar file contains IBM APIs necessary to speak to the System i5. On the System i5 side, there are three objects used in the process: RPG2DT (*CMD), RPG2DTR (*PGM), and MYDQ (*DTAQ). The RPG2DT *CMD object is simply there to make it easy to call RPG2DTR from the command line. The definition for RPG2DT is shown in Figure 1.
Figure 1: This is the command definition for RPG2DT.
Figure 2: Pass the unique key to use when writing to the data queue, the PC command you want executed, and the data queue library and name. Figure 3: Run RPGToDesktop. (Click image to enlarge.)
Figure 4: These are some examples of calling command RPG2DT. Environment This was tested and implemented on Windows XP. Obviously, if you have multiple desktop OSes in your shop, you will have to code and account for all the different scenarios. | ||||||
View all articles by this author
|
||||||
| Last Updated on Tuesday, 27 January 2009 08:37 |
| MC Press Web Site Staff |
TechTip: RPG Talks to the Desktop
Nov 25 2007 22:16:00 This is a discussion about TechTip: RPG Talks to the Desktop.
|
#145208 |
| Denny Davis |
TechTip: RPG Talks to the Desktop
Nov 07 2007 15:24:00 I don't want to hard code the profile and password in the batch file. How do I just bring up to signon prompt. Passing " " works after you get the error message. Denny
|
#145209 |
| aaronbartell@gmail.com |
TechTip: RPG Talks to the Desktop
Nov 07 2007 17:50:00 You should be able to achieve your objective by changing this line: host = new AS400(this.sys, this.usr, this.pw); to be host = new AS400(this.sys); in the RPGToDesktop.java object. Note you will have to rebuild the Java after the change. I use Eclipse for that. HTH, Aaron Bartell http://mowyourlawn.com
|
#145210 |
| aaronbartell@gmail.com |
TechTip: RPG Talks to the Desktop
Nov 25 2007 22:16:00 DBizon, it sounds like this is an object resolution issue (i.e. the program either didn't compile or it wasn't found given your library list). Please double check the program compiled successfully. Aaron Bartell http://mowyourlawn.com
|
#145212 |
| aaronbartell@gmail.com |
Re:TechTip: RPG Talks to the Desktop
Dec 15 2007 22:30:24 This is a question sent to me (the author of this article) that I wanted to share with the rest of the thread in case somebody else makes the same mistake. I'm trying to follow the samples in your article "RPG Talks to the Desktop" I don't get the expected results when I start the .bat file. My screen flashes the .bat file but I don't see the messages you show in the article. This is what is in my .bat file: START javaw -cp jt400.jar;RPG2DT.jar com.mowyourlawn.RPGToDesktop The problem here is that the greater than and less than signs were kept in place. I should have declared that those needed to be taken out and were simply used as delimiters. An example of a valid invoking string would be as follows: START javaw -cp jt400.jar;RPG2DT.jar com.mowyourlawn.RPGToDesktop 192.168.0.33 JUSTIN DDFF3322 QGPL RTDDQ 00001 Let me know if you still have problems. Aaron Bartell http://mowyourlawn.com
|
#151674 |






