Each year, I learn two or three things about the iSeries or AS/400 that have often been around for years, but I never ran across them. About 10 years ago, my good friend Greg Veal (author of CL Programming for the IBM AS/400) told me that second-level prompting was available on the IF statement in CL. If you prompt the IF command, you can then prompt the command you want to run on the THEN parameter by positioning the cursor in the THEN parameter on the prompter and then pressing the F4 key.
I've used this technique on the SBMJOB command interactively for years, and that was why I was complaining about it to him with regard to the IF statement. It never occurred to me to press F4 in the THEN parameter.
Recently, I learned about remote output queues. I needed to be able to send the output from one AS/400 to another over the Internet. The only true connection was TCP/IP over the Internet and not much else.
So I started to write a tool that would copy a spool file to a database file and then evoke FTP to send the file to the other system. At the other end, I would use a never-ending batch program to periodically test a file for the new member and then print it to the local printer. Imagine how dumb I felt after asking a few questions of some colleagues on the RPG newsgroups and email lists.
Remote OUTQs
You can actually do what I wanted to do by simply creating an output that points to an IP address and an existing output queue on an AS/400 somewhere on the Internet.
Yes, that's right: Using your IP address and the name of an output queue, anyone can send you a spool file that will sit in that output queue until you print it or delete it.
To create a remote output queue, all you have to do is enter the IP address of the remote system, identify the output queue name on that remote system, and--optionally but highly recommended--specify very clear text as to where the output is located. Here's an example command to create a remote output queue:
RMTPRTQ('*LIBL/QPRINT') CNNTYPE(*IP) TRANSFORM(*NO) +
TEXT('RPG xTools i5 520 output queue')
In this example, the output queue LUNA7 is created on the local system, and it points to the remote system at the dummy IP address specified. (You would specify a real IP address of one of your own systems.) The output queue on the remote system is QPRINT. Note that the connection type is set to *IP and that I've chosen to not transform the output.
Use the remote output queue just like any local output queue; simply write to the output queue or use option 2 on WRKSPLF or similar commands to move existing spool files to the remote printer. The system takes care of sending the spool file to the remote system and spooling it up there.
If you have a firewall, you may need to open the port for this capability to function. If your first attempt at sending a spool file to the remote output fails, look at the second-level text of the low-level joblog messages for the port number.
Bob Cozzi is a programmer/consultant, writer/author, and software developer. His popular RPG xTools add-on subprocedure library for RPG IV is fast becoming a standard with RPG developers. His book The Modern RPG Language has been the most widely used RPG programming book for more than a decade. He, along with others, speaks at and produces the highly popular RPG World conference for RPG programmers.
LATEST COMMENTS
MC Press Online